gpt4 book ai didi

android - 使用 Android 7 的 FileUriExposedException

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:49:41 25 4
gpt4 key购买 nike

<分区>

当我尝试拍摄照片时出现此错误:

FATAL EXCEPTION: main android.os.FileUriExposedException: file:///storage/emulated/0/fname_1498727381241.jpg exposed beyond app through ClipData.Item.getUri() at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799) at android.net.Uri.checkFileUriExposed(Uri.java:2346) at android.content.ClipData.prepareToLeaveProcess(ClipData.java:835) at android.content.Intent.prepareToLeaveProcess(Intent.java:9514) at android.content.Intent.prepareToLeaveProcess(Intent.java:9499) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1525) at android.app.Activity.startActivityForResult(Activity.java:4403) at android.app.Activity.startActivityForResult(Activity.java:4362) at opteamit.com.belami.CommuniquerPartagerPhotosActivity$1.onClick(CommuniquerPartagerPhotosActivity.java:46) at android.view.View.performClick(View.java:6261) at android.view.View$PerformClick.run(View.java:23752) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6776) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)

它之前工作正常,但问题似乎是因为我使用的是 Android 7 (API 24)。

这是我的代码:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
imageUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "fname_" +
String.valueOf(System.currentTimeMillis()) + ".jpg"));
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);

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