2

I am getting-

java.lang.SecurityException: Permission Denial: opening provider com.android.providers.media.MediaDocumentsProvider from ProcessRecord{..} requires android.permission.MANAGE_DOCUMENTS or android.permission.MANAGE_DOCUMENTS

at

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

I am using bm = MediaStore.Images.Media.getBitmap(context.getContentResolver(), uri); inside a service.I normally does NOT get this exception but if i reboot my device and then service gets called i get this exception.I have specified android.permission.MANAGE_DOCUMENTS in manifest as well as at runtime and i have checked Getting Permission Denial Exception answer too.

Community
  • 1
  • 1
Android Developer
  • 9,157
  • 18
  • 82
  • 139
  • Where is `uri` coming from? When and where did you get that `Uri`? How is your service getting that `Uri`? – CommonsWare Feb 07 '17 at 16:09
  • @CommonsWare I opened gallery from my activity and uri is coming from the selected image by user.Then i am using service to post that image to server when network connection is there using job scheduler.So if that service gets called after rebooting device i get this crash – Android Developer Feb 07 '17 at 16:11
  • @CommonsWare Suppose user selected image from gallery and network connection was not there..i scheduled that service using job scheduler.Then if i reboot my device i get this crash.. – Android Developer Feb 07 '17 at 16:12
  • http://stackoverflow.com/a/42078089/115145 – CommonsWare Feb 07 '17 at 16:13
  • @CommonsWare Thanks a lott !! It worked with takePersistableUriPermissions() – Android Developer Feb 07 '17 at 18:19

0 Answers0