简体   繁体   中英

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?

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() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM