Android dynamic permission application

tags: android  android studio  android-studio

// Judgment permissions
if (PackageManager.PERMISSION_GRANTED != ActivityCompat.checkSelfPermission(
                this,
                permission.CAMERA
            ) || PackageManager.PERMISSION_GRANTED != ActivityCompat.checkSelfPermission(
                this,
                permission.WRITE_EXTERNAL_STORAGE
            ) || PackageManager.PERMISSION_GRANTED != ActivityCompat.checkSelfPermission(
                this,
                permission.READ_EXTERNAL_STORAGE
            )
        ) {
 // Apply for acquisition permissions
            ActivityCompat.requestPermissions(
                this, arrayOf(permission.CAMERA,permission.WRITE_EXTERNAL_STORAGE,permission.READ_EXTERNAL_STORAGE), 10001
            )
        }else{
                         // Other operations after execution
        }

In addition to applying in Androidmanifest.xml in the Android permission application, the above method can be used where dynamic obtaining permissions can be used.

<USES-PERMISSION android: name = "Android.Permission.System_alert_window" /> <!
         <USES-PERMISSION android: name = "Android.Permission.access_Coarse_Location" /> <!-Used to access GPS positioning->
         <USES-PERMISSION android: name = "Android.Permission.access_fine_location" /> <!
         <USES-PERMISSION android: name = "Android.Permission.access_network_State" /> <!
         <USES-PERMISSION android: name = "Android.Permission.access_wifi_State" /> <!
         <USES-PERMISSION android: name = "Android.Permission.change_wifi_State" /> <!
         <USES-PERMISSION android: name = "Android.Permission.internet" /> <!-Used to read the current state of the mobile phone->
         <USES-PERMISSION android: name = "Android.permission.read_phone_State" /> <!
         <USES-PERMISSION android: name = "Android.Permission.write_extRNAL_STORAGE" /> <!
         <USES-PERMISSION android: name = "Android.Permission.Access_Location_Extra_commands" /> <!

Intelligent Recommendation

PAT 1018 Public Bike Management (Dijkstra+dfs)

There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return it to any other stations in the ...

Write aligned output in C

Description: Read three integers, each integer takes up to 8 characters, and right-aligns them. Input: There is only one line, containing three integers separated by a space. Output: There is only one...

Performance Comparison of Lightweight Lock available in C ++ under Linux

Background introduction In the current work, there is a scene, there is a read / write operation of a variable with a lower collision chance, in order to ensure the safety of operation, you need to ad...

PHP verification code tool

Captcha.class.php:...

Sensor learning-ESP8266 (use of wireless serial port)

The ESP8266 module is a high-performance WIFI serial port module. As long as you know how to program the serial port, you can achieve the so-called transparent transmission. Connect usb to ttl as foll...

More Recommendation

Eclipse download, installation, inspection and installation and uninstall

Eclipse download, installation, inspection and installation and uninstall Step 1: Download Eclipse installation Download link: http://www.eclipse.org/downloads/ 1. Click Download Packages to enter the...

Final keyword

Decorative class: Indicates that the class cannot be inherited Modification method: means that the method cannot be rewritten (ie, it is not expandable), but it can be overloaded within the class. Mod...

Query a subset of the collection from the file via Socket

Article Directory Query a subset of the collection from the file Server-side code program example Client program code example File.txt Test screenshot The server started successfully Client started su...

Graphical traversal of binary tree

Introduction to the front, middle and back of the binary tree For a binary tree, preorder (left and right root), middle order (left and right root), and postorder (left and right root). It can be simp...

Algorithm Graphic Learning Notes (1) - Binary

Python Realization ----- Binary ---- Principle: Differential inquiry target elements, is to select the middle element to determine whether it is big or small. If you choose the previous half, repeat t...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top