【问题标题】:ACTION_IMAGE_CAPTURE on samsung device blurred三星设备上的 ACTION_IMAGE_CAPTURE 模糊
【发布时间】:2019-03-12 17:01:32
【问题描述】:

我正在使用此代码打开相机意图:

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

【问题讨论】:

    标签: android android-camera samsung-mobile


    【解决方案1】:

    您必须在相机意图中提供照片路径 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 本身中的捕获图像

    【讨论】:

    • 这就是预览看起来平滑的原因吗?因为它是缩略图?还有为什么只有三星?
    • 是的,因为您只获得缩略图。我敢肯定它也发生在其他设备上。
    • 这是正确的答案,只需要实现 fileprovider 就可以了
    猜你喜欢
    • 1970-01-01
    • 2019-08-04
    • 2016-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多