Android App Launch page load all permissions dynamically

Source: Internet
Author: User

First, write in front

More than 6.0 dynamic load permissions are loaded, requiring the user to manually assign permissions (dangerous Permissions), only these, other permissions do not load

Owning Permission group permissions
Calendar Read_calendar
Calendar Write_calendar
Camera Cameras
Contact person Read_contacts
Contact person Write_contacts
Contact person Get_accounts
Location Access_fine_location
Location Access_coarse_location
Microphone Record_audio
Phone Read_phone_state
Phone Call_phone
Phone Read_call_log
Phone Write_call_log
Phone Add_voicemail
Phone Use_sip
Phone Process_outgoing_calls
Sensor body_sensors
SMS Send_sms
SMS Receive_sms
SMS Read_sms
SMS Receive_wap_push
SMS Receive_mms
Storage Read_external_storage
Storage Write_external_storage

Second, the use of the framework RxPermissions2

In the Build.gradle file
Add dependency in dependencies {}
Compile ' io.reactivex.rxjava2:rxandroid:2.0.1 '
Compile ' io.reactivex.rxjava2:rxjava:2.0.1 '
Compile ' com.tbruyelle.rxpermissions2:rxpermissions:[email protected] '

Three, the key code
1 /**2 * Permission list3  */4string[] Permissions =Newstring[]{5 Manifest.permission.CAMERA,6 Manifest.permission.READ_PHONE_STATE,7 Manifest.permission.WRITE_EXTERNAL_STORAGE,8 Manifest.permission.READ_EXTERNAL_STORAGE9 };Ten  One /** A * Request Permission -  */ - Private voidrequestpermissions () { theRxpermissions rxpermission =NewRxpermissions ( This); - rxpermission -. Request (permissions)//multiple permissions separated by "," -. Subscribe (Granted- { +                 if(granted) { -                     //all permissions are obtained + textview.setanimation (animationset); A}Else { at                     //at least one permission has not been obtained -Toast.maketext (splashactivity. This, "Please give the app full permissions, otherwise you won't be able to use", Toast.length_short). Show (); - finish (); -                 } -             }); -  in}

Four, the framework upgrade is relatively fast, many of the online blog writing this framework is not practical, or to pay attention to its GitHub web site documentation

Address: Https://github.com/tbruyelle/RxPermissions

Android App Launch page load all permissions dynamically

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.