Grant permission required for EXTERNAL_STORAGE on Android M?

Will the Android permission WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE launch a new Android M grant resolution dialog?

+7
android android-6.0-marshmallow permissions
source share
6 answers

I agree with Guillaume Perrault's answer. I came across a similar question when I write READ_WRITE_EXTERNAL_STORAGE permission in AndroidManifest.xml

without the rights displayed in the application by default, people need to switch the storage switch button in the application permissions. Then I change my targetSdkVersion in build.gradle to 23(MNC) and another number associated with sdkVersion , the application is installed with permissions.

Another way is to write the requestpermission function in the place where resolution is required. The code is as follows:

  if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)== PackageManager.PERMISSION_GRANTED) { //do the things} else { requestPermissions(new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, AnyNumber); 

Because I have less than 15 reputations, so I cannot vote for Guillaume Perrault's answer. Just use this method to show your idea.

+9
source share

I decided to add this if I check the version for Android M

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions(new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1); requestPermissions(new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, 1); } 
+5
source share

My answer is based on my tests on the M Preview SDK version 2 using an emulator.

If you target the MNC preview API level, WRITE_EXTERNAL_STORAGE not provided by default and will be part of the new dynamic permissions API.

You will see the storage permission as a toggle button in the new application permissions menu in the device settings, and you can use Activity.requestPermissions to display a pop-up window for this permission.

However, if you target the api <MNC level, it will not be classified as a dangerous permission and thus will be provided without the ability to disable it (not displayed in the permission settings), and you will not be able to compile the code using Activity.requestPermissions anyway since the preliminary SDK provides minSdkVersion="MNC" using the new APIs.

This is a different behavior than placement permissions: regardless of the level of API you are aiming for, the user will be able to disable the location in the permissions menu.

For the permissions menu itself, the enable permission status is enabled by default if:

  • Target API Level <MNC.
  • Target API level = MNC, but you are updating the application on the device from a previous installation, where the target API level is less than the MNC.

Otherwise, the switch will be disabled by default.

Hope this helps.

+2
source share

According to the docs:

Limited permissions granted during installation: when a user installs or updates an application, the system provides the application with all the permissions that application requests fall under PROTECTION_NORMAL.

So, since READ_EXTERNAL_STORAGE falls under PROTECTION_NORMAL, it does not start a dialog.

But since the WRITE_EXTERNAL_STORAGE level is PROTECTION_DANGEROUS, it falls under this behavior, as described in the docs:

The user allows permissions at runtime: when the application asks for permission, the system displays a dialog to the user and then calls the application's callback function to notify it of whether permission has been granted. If the user grants permission, the application receives all the permissions in this functional permission area that were declared in the application manifest.

Here are the sources for the level of protection:

detailed list

0
source share

According to Android docs, you do not need to request permission to read and write external storage.

Edit: In the latest version of Android M, you need to request read and write permissions.

0
source share

Storage permits fall under the level of hazardous protection. Thus, all dangerous permissions of the protection level will not be granted during installation in Android M, if the target application SDK is set to 23. They will be specified at runtime. And yes, these permissions can be revoked at runtime.

The rights dialog does not start automatically, you need to make a request using an API, such as the requestPermissions () method, to show this native dialog.

Please check the list of permissions for dangerous level here

0
source share

All Articles