Eddie
Eddie

Reputation: 181

Permission automatically granted Android

My device is running Android 6 with MIUI 8, and it doesn't require for me to ask permission to access gallery.

Intent intent = new Intent(Intent.ACTION_PICK, 
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    startActivity(intent);

That's all I added to the onCreate method, and I haven't added the permission in the manifest? Why does it do that? Don't I have to grant a permission, before an app can access my gallery?

Upvotes: 0

Views: 613

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007658

it doesn't require for me to ask permission to access gallery

ACTION_PICK does not usually require a permission.

Also, your code does not necessarily "access gallery". It starts an activity. That activity could be one of several, depending on what the user has installed.

I haven't added the permission in the manifest?

There is no relevant permission for the code in your question.

You may be thinking of READ_EXTERNAL_STORAGE and/or WRITE_EXTERNAL_STORAGE. You might need those permissions to read in whatever content the user picks. However, you are not getting what the user picks, as you are using startActivity() and not startActivityForResult().

Upvotes: 3

Related Questions