Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android 6 runtime permission for accessing gallery

I got questions about Android 6 (Marshmallow) runtime permission. If user wants to pick a photo from gallery, should we ask for READ_EXTERNAL_STORAGE permission?

Seems like I could access the gallery even though I turn off the Storage permission.

like image 971
Shumin Avatar asked Sep 26 '22 05:09

Shumin


1 Answers

You need to ask for READ_EXTERNAL_STORAGE. You will be able to access the gallery without it, but if you want to do anything with the media you get from the gallery you will need the READ permission.

A quick test on what happens in onActivityResult after an image has been picked form the gallery:

Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=8405, uid=10177 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()

like image 140
lostintranslation Avatar answered Sep 30 '22 05:09

lostintranslation