Android 6.0 Privilege judging Audio photo album

Source: Internet
Author: User

------------------------------------------Turn on Audio permissions------------------------------------------------if(packagemanager.permission_granted = =Contextcompat. Checkselfpermission (Context, Android. Manifest.permission.RECORD_AUDIO)) {}Else{                    //Prompt user to open an account right audioString[] perms = {"Android.permission.RECORD_AUDIO"}; Activitycompat.requestpermissions (chatactivity. This, perms, Result_code_startaudio); } @Override Public voidOnrequestpermissionsresult (intPermsrequestcode, string[] permissions,int[] grantresults) {        Switch(permsrequestcode) { CaseResult_code_startaudio:Booleanalbumaccepted = grantresults[0]==packagemanager.permission_granted; if(!albumaccepted) {toastutil.show (context,"Please turn on app recording permission"); }                 Break; }    }------------------------------------------to open the Take photo permission------------------------------------------------//determine whether to open a photo album permissions                                if(packagemanager.permission_granted = =contextcompat.checkselfpermission (Context, Android.                                Manifest.permission.CAMERA)) {Camera.startcameraurl (context, filename, CAMERA); }Else{                                    //prompt the user to open a permissionString[] perms = {"Android.permission.CAMERA"}; Activitycompat.requestpermissions (broadcast_publish. This, perms, Result_code_startcamera); } @Override Public voidOnrequestpermissionsresult (intPermsrequestcode, string[] permissions,int[] grantresults) {        Switch(permsrequestcode) { CaseResult_code_startcamera:Booleancameraaccepted = grantresults[0]==packagemanager.permission_granted; if(cameraaccepted) {//after the authorization is successful, call the system camera to take a photo operation, etc.camera.startcameraurl (context, filename, Camera); }Else{                    //after the user authorizes the refusal, the friendly hint will be ableToastutil.show (Context, "Please open app photo permission"); }                 Break;}}------------------------------------------Open Album Permissions------------------------------------------------if(packagemanager.permission_granted = =Contextcompat. Checkselfpermission (context, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {Intent inte NT=NewIntent (context, photoalbumactivity.class);                                Context.startactivity (Intent); }Else{                                    //prompt the user to open a permissionString[] perms = {"Android.permission.WRITE_EXTERNAL_STORAGE"}; Activitycompat.requestpermissions (broadcast_publish. This, perms, result_code_startstorage); } @Override Public voidOnrequestpermissionsresult (intPermsrequestcode, string[] permissions,int[] grantresults) {        Switch(permsrequestcode) { CaseResult_code_startstorage:Booleanalbumaccepted = grantresults[0]==packagemanager.permission_granted; if(albumaccepted) {Intent Intent=NewIntent (context, photoalbumactivity.class);                Context.startactivity (Intent); }Else{                    //after the user authorizes the refusal, the friendly hint will be ableToastutil.show (Context, "Please open app photo permission"); }                 Break; }    }

Android 6.0 Privilege judging Audio photo album

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.