這種共享的音頻文件是我的代碼:使用意圖
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("audio/*");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///"+filePath));
startActivity(Intent.createChooser(share, "Share Sound File"));
問題:由於某些原因,當我今天查這個程式碼nexus 5X API 26
仿真器,應用程序崩潰,而 我Xperia z5 premium
(API 25)它像一個魅力。
這段代碼有沒有可能與新的api不兼容?
logcat-
08-24 15:16:08.445 3050-3050/com.example.tsuryohananov.mycallrecorder E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.tsuryohananov.mycallrecorder, PID: 3050
android.os.FileUriExposedException: file:////storage/emulated/0/CallRecordings/24.08.2017 02-32-19 PM.m4a exposed beyond app through ClipData.Item.getUri()
at android.os.StrictMode.onFileUriExposed(StrictMode.java:1932)
at android.net.Uri.checkFileUriExposed(Uri.java:2348)
at android.content.ClipData.prepareToLeaveProcess(ClipData.java:941)
at android.content.Intent.prepareToLeaveProcess(Intent.java:9735)
at android.content.Intent.prepareToLeaveProcess(Intent.java:9741)
at android.content.Intent.prepareToLeaveProcess(Intent.java:9720)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1609)
at android.app.Activity.startActivityForResult(Activity.java:4471)
at android.app.Activity.startActivityForResult(Activity.java:4429)
at android.app.Activity.startActivity(Activity.java:4788)
at android.app.Activity.startActivity(Activity.java:4756)
at com.example.tsuryohananov.mycallrecorder.MainActivity$9.onClick(MainActivity.java:324)
at android.view.View.performClick(View.java:6219)
at android.view.View$PerformClick.run(View.java:24482)
at android.os.Handler.handleCallback(Handler.java:769)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6540)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
(線324是startActivity)
您可以發佈您的logcat的崩潰設備? –
https://stackoverflow.com/questions/38200282/android-os-fileuriexposedexception-file-storage-emulated-0-test-txt-exposed – CommonsWare
@OrkunKoçyiğit信息發佈 –