解決方案1:
android.os.FileUriExposedException: file:///storage/emulated/0/ilive/images/photophoto.jpeg exposed beyond app through ClipData.Item.getUri()
解決辦法:
將下面的代碼拷貝到application類里面,
// android 7.0系統解決拍照的問題 StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); StrictMode.setVmPolicy(builder.build()); builder.detectFileUriExposure();
這樣,問題就可以解決了。
解決方案2:
應用內自動升級,下載安裝包后拋出異常,先貼個錯誤
Log:
android.os.FileUriExposedException: file:///storage/emulated/0/aiyou.apk exposed beyond app through Intent.getData()
問題分析:
1.版本不支持
修改platforms>android
中的AndroidManifest.xml
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="23" />
- 1
盡量保持android:targetSdkVersion版本在24以下
If you have an app that shares files with other apps using a Uri, you may have encountered this error on API 24+.
2.權限問題
同樣修改AndroidManifest.xml
文件,添加
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
- 1
這個主要影響Android 8.x版本