For Android 7.0-oriented apps, the Android framework enforces an StrictMode API policy that prohibits exposing URIs outside your app file:// . If a intent that contains a file URI leaves your app, the app fails with an FileUriExposedException exception.
To share files between apps, you should send a content:// URI and grant temporary access to the URI. The simplest way to make this authorization is to use a FileProvider class.
Workaround:
First add <provider> in the <application> tab of Androidmanifest.xml
<!--file Sharing- <provider android:name= "Android.support.v4.content.FileProvider" android:authorities= "${application_id}.provider" android:exported= "false" Android:granturipermissions= "true" > <meta-data android:name= " Android.support.FILE_PROVIDER_PATHS " android:resource=" @xml/provider_paths "/> </ Provider>
Next, create the XML subfolder under the Res folder (if it already exists, ignore it) and new file Provider_paths.xml
The contents are as follows
<?xml version= "1.0" encoding= "Utf-8"?><paths> <external-path path= "." Name= "External_files"/ ></paths>
Next, when jumping, the URI passed in is no longer used
Uri.fromfile (tmpfile);
Instead, use Fileprovider's Geturiforfile () method to get
New Intent (mediastore.action_image_capture); NULL , Storageutils.getimagedir (context)); = Fileprovider.geturiforfile (context, + ". Provider", tempfile); Intent.putextra (Mediastore.extra_output, Imguri); Startactivityforresult (Intent, request_take);
Reference address
Android 7.0, take a picture error