Android 系统相机拍照后相片无法在相册中显示解决办法
Android系统相机拍照后相片无法在相册中显示解决办法
目前自己使用发送广播实现了效果
publicvoidphoto(){ IntentopenCameraIntent=newIntent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(openCameraIntent,TAKE_PICTURE); }
解决方法:
protectedvoidonActivityResult(intrequestCode,intresultCode,Intentdata){ switch(requestCode){ caseTAKE_PICTURE: if(resultCode==RESULT_OK){ StringfileName=String.valueOf(System.currentTimeMillis()); Bitmapbm=(Bitmap)data.getExtras().get("data"); FileUtils.saveBitmap(bm,fileName); StringimagePath=FileUtils.SDPATH+fileName+".JPEG"; //将刚拍照的相片在相册中显示 UrilocalUri=Uri.fromFile(newFile(imagePath)); IntentlocalIntent=newIntent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,localUri); sendBroadcast(localIntent); } break; }
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!