Android webview solution to encounter errors
1. Add in the Manifest file:
<manifest ...> <application ...> <provider android:name="." android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name=".FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/> </provider> </application> </manifest>
2. Create an XML file: res/xml/provider_paths.xml
<?xml version="1.0" encoding="utf-8"?> <paths xmlns:andro> <external-path name="external_files" path="."/> </paths>
3. Replace the URI code of the get file with a new API:
... imageUri = (createImageFile()); replace with : File file = createImageFile(); imageUri = (mActivity, () + ".provider", file); ...
If you have any questions, please leave a message or go to the community of this site to exchange and discuss. Thank you for reading. I hope it can help you. Thank you for your support for this site!