Android webview 遇到android.os.FileUriExposedException錯誤解決辦法
更新時間:2017年10月25日 09:02:54 作者:_iorilan
這篇文章主要介紹了Android webview 遇到android.os.FileUriExposedException錯誤解決辦法的相關(guān)資料,希望通過本文能幫助到大家,讓大家遇到這樣的問題解決,需要的朋友可以參考下
Android webview 遇到android.os.FileUriExposedException錯誤解決辦法
1. 在 Manifest 文件中添加:
<manifest ...> <application ...> <provider android:name="android.support.v4.content.FileProvider" android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/> </provider> </application> </manifest>
2. 創(chuàng)建 XML 文件: res/xml/provider_paths.xml
<?xml version="1.0" encoding="utf-8"?> <paths xmlns:android="http://schemas.android.com/apk/res/android"> <external-path name="external_files" path="."/> </paths>
3. 把獲取文件URI代碼替換成新的api:
... imageUri = Uri.fromFile(createImageFile()); replace with : File file = createImageFile(); imageUri = FileProvider.getUriForFile(mActivity, mActivity.getPackageName() + ".provider", file); ...
如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
Android 出現(xiàn)“Can''t bind to local 8602 for debugger”錯誤的解決方法
這篇文章主要介紹了Android 出現(xiàn)“Can't bind to local 8602 for debugger”錯誤的解決方法的相關(guān)資料,需要的朋友可以參考下2017-03-03android開發(fā)之蜂鳴提示音和震動提示的實現(xiàn)原理與參考代碼
蜂鳴提示音和震動提示此功能在手機使用中很實用,最近在讀zxing項目,學到了不少東西;我們一起來看看他是怎么做的,感興趣的朋友可以了解下哦2013-01-01Android實現(xiàn)完整游戲循環(huán)的方法
這篇文章主要介紹了Android實現(xiàn)完整游戲循環(huán)的方法,以實例代碼形式較為詳細的分析了Android游戲循環(huán)的實現(xiàn)技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-10-10