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