Android 7.0以上版本 系統解決拍照的問題 exposed beyond app through ClipData.Item.getUri()


解決方案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版本


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM