Declare and use permissions, and declare Permissions

Source: Internet
Author: User

Declare and use permissions, and declare Permissions

AndroidManifest. xml

<? Xml version = "1.0" encoding = "UTF-8"?> <Manifest xmlns: android = "http://schemas.android.com/apk/res/android" package = "com. scott. phone" android: versionCode = "1" android: versionName = "1.0"> <! -- Declare a permission --> <permission android: protectionLevel = "normal" android: name = "scott. permission. MY_CALL_PHONE "/> <application android: icon =" @ drawable/icon "android: label =" @ string/app_name "> <activity android: name = ". mainActivity "android: label =" @ string/app_name "> <intent-filter> <action android: name =" android. intent. action. MAIN "/> <category android: name =" android. intent. category. LAUNCHER "/> </intent-filte R> </activity> <! -- Defined permissions for the Activity Application --> <activity android: name = ". PhoneActivity" android: permission = "scott. permission. MY_CALL_PHONE"> <intent-filter> <! -- Note that this action can be used to access this Activity in other applications --> <action android: name = "scott. intent. action. MY_CALL "/> <category android: name =" android. intent. category. DEFAULT "/> </intent-filter> </activity> </application> <! -- Permissions must be added to access PhoneActivity in the same application --> <uses-permission android: name = "scott. permission. MY_CALL_PHONE "/> <uses-sdk android: minSdkVersion =" 8 "/> </manifest>

It should be noted that an android: protectionLevel attribute is required for the declared permission, which represents the "risk level ". Must be one of the following values:

Normal, dangerous, signature, signatureOrSystem.
Normal indicates that permissions are low-risk and do not cause harm to systems, users, or other applications.
Dangerous indicates that the permission is high. The system may require the user to enter relevant information before granting the permission.
Signature tells Android that the permission can be granted only when the digital signature used by the application is the same as all the digital signatures of the application that declares this permission.
SignatureOrSystem tells Android to grant permissions to applications or Android packages with the same digital signature. This level is applicable to special situations, such as when multiple vendors need to share images through the system function.
The other is the android: permissionGroup attribute, indicating a permission group. You can place permissions in a group, but do not set this attribute for custom permissions. If you do want to set this property, you can replace it with the following property: android. permission-group.SYSTEM_TOOLS.

Note thatAndroid: protectionLevelIt represents the "risk level ". Must be one of the following values:

 

Normal, dangerous, signature, signatureOrSystem.

NormalIt indicates that permissions are low-risk and do not cause harm to systems, users or other applications.

DangerousThis indicates that the permission is high. The system may require the user to enter relevant information before granting this permission.

SignatureTell Android that the permission can be granted only when the digital signature used by the application is the same as all the digital signatures of the application that declares this permission.

SignatureOrSystemTell Android to grant permissions to apps with the same digital signature or Android packages. This level is applicable to very special situations. For example, when multiple vendors need to share system images.

The other one isAndroid: permissionGroupAttribute, indicating a permission group. You can place permissions in a group, but do not set this attribute for custom permissions. If you do want to set this property, you can replace it with the following property: android. permission-group.SYSTEM_TOOLS.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.