Permission mechanism and usage details of Android permission management
preface:
*** However, I don't want to directly enter this topic, so I choose to learn about the permission mechanism and usage of Android first
Android permission mechanism:
Permission is a security mechanism. Android permissions are mainly used to restrict the use of some restrictive functions within applications and the access of components between applications.
Android permission list:
Android permission usage:
1.) use < uses Permission > in the < manifest > tag of androidmanifest.xml to declare the use of a certain permission
For example, apply for network permission
If a specific permission must be declared for use, a permission deny error will be reported if it is not applied for use. For example, the following error will be reported when accessing the address book
Caused by: java.lang.SecurityException: Permission Denial: reading com.androintacts.ContactsProvider2 uri content://contacts/data/phones from pid=23763,uid=10036 requires android.permission.READ_ CONTACTS
To solve this kind of error, we just need to add the corresponding permission according to the prompt
2.) user defined permission
Although such usage scenarios are rare, in some specific scenarios, custom permissions are required for security reasons. For example, ContentProvider is used to share data between two apps. At this time, when we need to access the data of another app, we need to add permission application. Custom permissions can be accessed through the < Permission > tab
For ordinary and dangerous level permissions, we call them low-level permissions, and the application application is granted. The other two levels of permissions are called advanced permissions or system permissions. When an application attempts to perform a restricted operation without permission, the application will be killed by the system for warning. The system application can use any permission. The declarant of the permission can use the permission unconditionally.
According to the above introduction, we will customize the permissions as follows
3.) user defined permission group
In order to facilitate the management of permissions for a specific function, I will group permissions. At this time, we need to customize a permission group through < permission group >
The above permission group can be customized as follows:
Other permission trees are not introduced here. This has not been used so far. < permission tree > declares a namespace for a group of permissions.
4.) use custom permissions
Apply for permission
Claim that access needs to be requested on the host
Summary:
This chapter has a general understanding of Android permission and how to use and customize permissions. The next chapter will summarize and learn how to solve the permission adaptation problem of Android 6.0.
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.