9

I am getting-

java.lang.SecurityException: Permission Denial: opening provider com.android.providers.media.MediaDocumentsProvider from ProcessRecord{f1d408f 5594:firebasejobscheduler.test.com.firbasejobschedulerdemo/u0a1227} (pid=5594, uid=11227) requires android.permission.MANAGE_DOCUMENTS or android.permission.MANAGE_DOCUMENTS

at

 bm = MediaStore.Images.Media.getBitmap(context.getContentResolver(), uri);

I have checked this post but not able to resolve it.How can i resolve this?

Community
  • 1
  • 1
Android Developer
  • 9,157
  • 18
  • 82
  • 139

2 Answers2

2

You must check for RunTimePermissions in Marshmallow. check this link . check it for READ_EXTERNAL_STORAGE permission

  • 2
    believe me its not working, securityException comes only when your application is not allowing some permission... your exception asking for **android.permission.MANAGE_DOCUMENTS** permission.. try for this permission too.. – Chinmay Thoriya Feb 07 '17 at 11:52
  • If you want to check your app anyway, then in your android device go to setting-> application->_yourapp_->permissions-> allow all the permissions required, **but its not recommended**, you should provide UI for allowing permission from application.. here you can see what permissions are required – Chinmay Thoriya Feb 07 '17 at 11:59
  • i have added permission in both manifest and at runtime..i already checked that..i am using `bm = MediaStore.Images.Media.getBitmap(context.getContentResolver(), uri);` inside service and after i rebbot device if my service starts i get this crash – Android Developer Feb 07 '17 at 15:45
  • are you saving the permission status in sharedPreferences ? It may happen if you dont save permission status. – Chinmay Thoriya Feb 09 '17 at 08:24
1
public void chooseImage() {
    Intent i = new Intent();
    i.setType("image/*");
    //i.setAction(Intent.ACTION_GET_CONTENT);
    i.setAction(Intent.ACTION_OPEN_DOCUMENT);

    //ActivityResultLauncher for opening the gallery
    getImageFromGallery.launch(i);

}

That chooseImage() is a function to open the gallery. If you have checked that you have the permission READ_EXTERNAL_STORAGE already requested and accepted by the user, try changing or commenting i.setAction(Intent.ACTION_GET_CONTENT) to i.setAction(Intent.ACTION_OPEN_DOCUMENT).

MosesK
  • 359
  • 3
  • 7