Android Basics-The new access system for Android 6.0

Source: Internet
Author: User

After the Android 6.0 version, the new permission system appeared, in order to better protect the user's security, the new permission system requires the developer to manually apply in code, so in order to fit the 6.0 privilege system, we have to learn the authority system

Android 6.0 new permissions system classification there are two types of

    1. Normal permission (normal): This type of permission does not directly threaten the privacy of the user, can be directly registered in the manifest list, the system will help us to authorize the default
    2. Dangerous Permissions (Dangerous): This can directly to the app to access the user some sensitive data, not only need to register in the manifest list, while in use, you need to request authorization to the system

Characteristics of dangerous rights

    • Dangerous permissions are assigned by group, and other permissions in the group are agreed by default as long as a permission for the same group is agreed upon

General Permissions List graph

Dangerous rights group diagram

The application of the authority is very humane, similar to our visa procedures, its application procedures are

    1. DECLARE this permission
    2. Check if the permission is already available
    3. Apply permission if not
    4. Receive request success or failure callback

① to use permissions, don't forget to apply in manifest

② apply for a single permission

③ requesting multiple permissions

If you want to apply for multiple permissions at the same time, you can transfer the permission to apply in the Requestpermissions

④ to determine the Android 6.0 system

For the rigor of the code, under the Android 6.0 we do not have to apply manually, it is necessary to determine the version of Android

Many times the user accidentally click on the refusal, or fear that the mobile phone information stolen and point of refusal, when the second time into the program, summary we have to do the corresponding processing, here first look at the following method of explanation

    • Shouldshowrequestpermissionrationale ()

      1. When a permission is requested for the first time, the user rejects it, returns true after calling Shouldshowrequestpermissionrationale (), and should show some explanation of why this permission is required
      2. After the user denies a permission for the first time, the next time you apply again, the "no reminder" option will appear in the authorized dialog, and once checked, the next application will not prompt the user
      3. The second time the permission is requested, the user rejects and selects the "Not in reminder" option, which returns false after calling Shouldshowrequestpermissionrationale ()

Knowing the principle of this method, then the code can be written out quickly, the following is directly affixed to the complete code

Realize

Android Basics-The new access system for Android 6.0

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.