Android - 相机闪退,SecurityException: Permission Denial: opening provider android.support.v4.content.FileProvider

java.lang.SecurityException: Permission Denial: opening provider android.support.v4.content.FileProvider from ProcessRecord ... that is not exported from....

This is due to the rights issue shareFile android7.0 above, can not be used directly pick File, to turn into a Uri to use


https://juejin.im/entry/586dbd798d6d8100586ac8e2

http://www.jianshu.com/p/358b5d791045

These two should be able to basically solve the problem

I do real OPPO R5 Android 4.4.4

When invoked with the intent camera, plus temporary permission to

    {the try 
            the Intent intent_camera the Intent new new = (android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
// fileUri = Uri.fromFile (getOutputMediaFile (. 1)); 
            fileUri = FileProvider.getUriForFile (appPublic, appPublic.getApplicationContext () getPackageName () +. " .fileprovider ", getOutputMediaFile (1)); 
            intent_camera.putExtra (MediaStore.EXTRA_OUTPUT, fileUri); 

            // this is it took me a whole day .... 
            List
 
 
  
   resolvedIntentActivities = appPublic.getPackageManager()
                  .queryIntentActivities(intent_camera, PackageManager.MATCH_DEFAULT_ONLY);
            for (ResolveInfo resolvedIntentInfo : resolvedIntentActivities) {
               String packageName = resolvedIntentInfo.activityInfo.packageName;
               appPublic.grantUriPermission(packageName, fileUri, FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
            }

            this.appPublic.startActivityForResult(intent_camera, CAMERA);
            System.gc(); //提醒系统及时回收
         }catch(Exception e){
            e.printStackTrace();
         }
 
 

Original: Big Box  Android - camera flash back, SecurityException: Permission Denial: opening provider android.support.v4.content.FileProvider


Guess you like

Origin www.cnblogs.com/petewell/p/11465705.html