gpt4 book ai didi

android - 三星设备上的 ACTION_IMAGE_CAPTURE 模糊

转载 作者:行者123 更新时间:2023-11-29 23:17:12 24 4
gpt4 key购买 nike

我正在使用此代码打开相机 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 行)

截图如下:

before

after[![][1] ] 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com