Android6.0 (API level 23) changes------Dynamic permissions

In addition to providing many new features and functions, Android 6.0 also introduces a new permission mode, allowing users to better understand and control permissions. Before this, everyone knows that adding permissions only needs to be applied in the AndroidManifest file, so let's learn about the dynamic permissions of Android 6.0 !


  • Android6.0 system permissions are divided into:
    • Normal Permissions (does not involve the privacy of mobile phone users, you can apply in the AndroidManifest configuration file, there should be nothing to say)
    • Dangerous Permission (involving privacy, needs to be added dynamically) To view all Dangerous Permission permissions, you can use the command:
      adb shell pm list permissions -g -d

The following focuses on how to add Dangerous Permission permissions.

  1. The first is to apply for the permissions we need in the configuration file AndroidManifest.
  2. Determine the phone system version. If it is not a version above Android 6.0 (including Android 6.0), proceed directly to the next step, otherwise apply for permission.

Note: The following operations are not required for systems other than Android 6.0 and above

  1. Check permissions.
    Check whether the user grants the permission through the ContextCompat.checkSelfPermission() method;
  2. The return value is: PERMISSION_GRANTED, indicating that the application has this permission and can continue to operate.
  3. The return value is: PERMISSION_DENIED, indicating that this permission is not granted to the application, and the permission needs to be requested from the user.
  4. Request permission.
    When the application does not have permission, it requests the corresponding permission from the user by calling ActivityCompat.requestPermissions().
  5. Process the permission request response.
    Whether the user is allowed to grant permissions is handled by the onRequestPermissionsResult() method.

The above is the method of requesting dynamic permissions that I understand, which is not difficult to understand.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325842546&siteId=291194637