[Android Development] using the system permissions process

Source: Internet
Author: User

1 Declaring Permissions https://developer.android.com/training/permissions/declaring.html

Each Android app runs in a restricted sandbox. If your app needs to use resources or information outside its sandbox, you must request the appropriate permissions . You can list the appropriate permissions in the app manifest, declaring that the app requires this permission.

Depending on the sensitivity of the permissions, the system may automatically grant permissions or require the device user to license the request. For example, if your app requests permission to turn on the device flashlight, the system will automatically grant that permission. However, if your app needs to read the user's contacts, the user will be asked to authorize them. Depending on the platform version, users need to grant permissions when installing apps (Devices running Android 5.1 and lower) or running apps (Devices running Android 6.0 and later).

Determine what permissions your app needs

When you develop your app, you should be aware of when your app uses features that require permissions. Typically, an app needs to have permission to use an information resource that is not created by itself, and to perform actions that affect the behavior of the device or other application. For example, if your app requires access to the Internet, uses a device camera, or turns on or off Wi-Fi, the app needs to have the appropriate permissions. To view a list of system permissions, see Normal permissions and Dangerous permissions.

Your app only needs permission to get the actions it directly performs. If your app requests another app to perform tasks or provide information, you don't need to get the appropriate permissions. For example, if your app needs to read the user's address book, READ_CONTACTS permissions are required. But if your app uses a intent to request information from the user's Contacts app, your app doesn't need any permissions, but the Contacts app does need that permission. For more information, see consider using intent.

Add permissions to the manifest

To declare that your app requires permissions, place the <uses-permission> element in your app manifest as a <manifest> child of the top-level element. For example, an app that needs to send a text message can add the following line of code to the list:

<manifest xmlns:android= 
        package< Span class= "pun" >= "Com.example.snazzyapp" >

    <uses-permission android:name= "Android.permission.SEND_SMS" />
   

    < Application ... >
        ...
    </application>

</ Manifest>

The behavior of the system after you declare permissions depends on the sensitivity of the permissions. If permissions do not affect user privacy, the system is automatically authorized. If the permission may involve access to sensitive user information, the user is asked to approve the request. To learn more about the different kinds of permissions, see Normal permissions and Dangerous permissions.

[Android Development] using the system permissions process

Related Article

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.