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