Uses-permission and permission detailed

Source: Internet
Author: User

1.<uses-permission>:

Official Description:

protected by a permission, it must declare the IT requires that permission with a  <uses-permission>  

Permission by checking the authorities so signed the application ' s certificates and, in some cases, asking the user. If the permission is granted,
The application is able to use the protected features. If not, it attempts to access those features would simply fail without any notification to the user.

If an application needs to access a permission protected feature, the app must declare its required permissions in manifest with the <uses-permission> node. When the application is installed on the device,

The installer will decide whether to grant the permission it declares, which sometimes asks the user. If the permission is granted, the app can use the protected attribute, otherwise the access fails and the user is not notified.

Note: It is not necessary to call other applications to declare <uses-permission>, and sometimes even call the components of the program you are applying to declare!!! (The following example will be said)

2. <permission>:



New permission is declared with the <permission>

An application can also use permissions to protect its own components, which can be defined using the Android system or other application-defined or application-defined permissions, if you want to define a new permission,

can be <permission> defined with a node. As follows:

<permission android:description= "string resource"  android:icon= "drawable resource"   Android:label= "string resource"  android:name= "string"  android:permissiongroup= " String "  android:protectionlevel=[" Normal "| "Dangerous" |        " Signature "| "Signatureorsystem"]/>

For example, a activity could be protected as follows:

<Manifest. . . >  <PermissionAndroid:name= "Com.example.project.DEBIT_ACCT" . . . />  <uses-permissionAndroid:name= "Com.example.project.DEBIT_ACCT" />  . . .  <Application. . .>    <ActivityAndroid:name= "Com.example.project.FreneticActivity"android:permission= "Com.example.project.DEBIT_ACCT"          . . . >      . . .    </Activity>  </Application></Manifest>
 This example, the DEBIT_ACCT permission are not only declared  with the <permission> element, it is also requested with the  <uses-permission>element.
for protected
<permission> element. However, it would still has been necessary to request their use with <uses-permission>.

Note that in this example, DEBIT_ACCT this permission is not only declared in <permission>, but also declared in <uses-permission>, in order to start the protected activity in other components of the application ,

It is necessary to declare DEBIT_ACCT in <uses-permission>, even if this protection is added to the application itself. (This confirms the 1th said above).

Note that if the added permission is defined elsewhere, there is no need to declare the <permission> again, but still use <uses-permission> to declare this permission.

Reference:

Http://developer.android.com/guide/topics/manifest/manifest-intro.html#perms

http://berdy.iteye.com/blog/1782854

http://blog.csdn.net/lilu_leo/article/details/6940941

Uses-permission and permission detailed

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.