我正在使用此代码打开相机 Intent :
Intent takePicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
takePicture.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
startActivityForResult(takePicture, 0);
它工作正常,但只适用于装有 Android 8 的三星设备 (8\9) 拍照后预览全是模糊的, 有人有这种奇怪的行为吗?
(我也试过没有 putExtra 行)
截图如下:
] 3
最佳答案
您必须在相机 Intent 中额外提供照片路径 Uri,如下所示:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(Environment.getExternalStorageDirectory(), mUserID + ".jpg");
Uri photoPath = getUriForFile(mContext, BuildConfig.APPLICATION_ID, file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoPath); //--> here
startActivityForResult(Intent.createChooser(intent, "Complete action using"), REQUEST_CODE_CAMERA);
然后,你就可以在onActivityResult中获取那个Uri本身的抓图了
关于android - 三星设备上的 ACTION_IMAGE_CAPTURE 模糊,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55117335/