The Android system groups all dangerous permissions, called permission groups. Dangerous permissions belonging to the same group will be automatically merged and granted. If the user grants the application permissions to a certain permission group, the application will obtain all permissions under the permission group (provided that the relevant permissions are declared in).
The list of hazardous permissions and permission groups is as follows: The permission group corresponding to the declared hazardous permissions can be viewed in the system "Settings" -> "Apps" -> "App Information" -> "Permissions", and you can manually authorize and cancel authorization.
1. If the device system is Android 6.0 (API 23) or higher, and the targetSdkVersion of the application is 23 or higher, then for the dangerous permissions declared in it, users need to be requested dynamically at runtime.
2. The API for dynamic permission request related operations is encapsulated in the .v4 package, and the Activity that initiates the permission request needs to be inherited directly or indirectly.
3. You can also initiate permission requests in a Fragment that inherits directly or indirectly.
Register first in the manifest file
Then encapsulate permissions into a String array
static final String[] PERMISSION = new String[]{ .READ_PHONE_STATE, .WRITE_EXTERNAL_STORAGE, .RECORD_AUDIO, .RECEIVE_BOOT_COMPLETED };
Then add the code to the onCreate() method:
if ((this, .READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { //Android 6.0 application permission (this, PERMISSION, 1); } else { (this, "success", Toast.LENGTH_SHORT).show(); }
I usually write the above code in another method and then call it in the onCreate() method.
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.