Android6.0 Dynamic Rights Management library Runtimepermission

Source: Internet
Author: User

In Android development, the application of a permission is very simple thing, but because Android6.0 out a dynamic permission, the whole complexity is a geometric multiplication. In the spirit of our development to the purpose of Jane, today I recommend a Android6.0 dynamic Rights Management Library runtimepermission, the following I would like to introduce its great use-the complexity of the simple!

First, take a look at the effect demo diagram:

Next, we introduce the function of the library and how to use it: 1. function

Android6.0 Dynamic Rights Management Library, callback mode management dynamic permissions, no need to pay attention to the various state of application permissions, only with care callback whether there is permission, and then do different logic processing!

2.Android Studio Integration Approach
dependencies{      compile ‘com.wkp:RuntimePermission:1.0.6‘      //Android Studio3.0+可用以下方式      //implementation ‘com.wkp:RuntimePermission:1.0.6‘}
3. Use the details (take the request camera permission as an example)
  • Manifest configuration
    <!--权限配置--><uses-permission android:name="android.permission.CAMERA"/>
  • code example

     //api 23@requiresapi (API = Build.version_codes. M) public class Mainactivity extends appcompatactivity {@Overrideprotected void onCreate (Bundle savedinstancestate) {su    Per.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main);} /** * Click to get permission * @param view */public void Applypermission (Final view view) {//permission check, callback is the result of permission request RUNTIMEPERMISSIONUTIL.C Heckpermissions (This, Runtimepermissionutil.camera, new Permissioncallback () {@Override public void OnCheck Permissionresult (Boolean haspermission) {if (haspermission) {//directly after the operation with permission Toas                T.maketext (Mainactivity.this, "permission to apply successfully", Toast.length_short). Show ();            ((TextView) view). SetText ("Permission to apply for success");                 }else {//display permission does not have interface Toast.maketext (mainactivity.this, "Permission request Failed", Toast.length_short). Show ();            ((TextView) view). SetText ("Permission request Failed"); }        }    });}}

    Note: The permission request uses the callback mode, does not care about the Android version, the built-in judgment all, always has the callback, the low version default true!

Conclusion

Control supports direct code creation, and there are more APIs to see the note descriptions in Runtimepermissionutil.java.

Welcome to use GitHub address, feel good please give a star encouragement, thank you!

If you have better ideas or suggestions and good inspiration, please email author, thank you!

QQ Email:
[Email protected]

163 e-Mail:
[Email protected]

Gmail Email:
[Email protected]

Android6.0 Dynamic Rights Management library Runtimepermission

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.