我写的应用程序用标准相机活动做照片。
private void makePhoto() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
File photoFile = null;
try {
photoFile = RFileManager.createImageFile();
imgUrl = photoFile.getAbsolutePath();
} catch (IOException e) {
}
if (photoFile != null) {
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
}
}
}
当我关闭相机活动时,我会尝试显示图片的缩略图。我通过此代码获取位图
Bitmap bitmap = BitmapFactory.decodeFile(path);
在Android 4.x-5版本中,它正确获取位图,但在android 6位图中为null,但如果我将等待大约10秒并关闭相机活动,则所有工作正常。我有所有必要的运行时权限的请求。我如何解决缩略图问题?