Android Permissions - Managing User Permissions in Android Development

slide1 n.w
1 / 7
Embed
Share

Learn how to manage user permissions in Android development, including the categories of normal and dangerous permissions, obtaining permissions in old and new ways, requesting permissions at runtime, and checking permissions dynamically.

  • Android Development
  • User Permissions
  • Permissions Management
  • Runtime Permissions
  • Android Manifest

Uploaded on | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. ANDROID PERMISSIONS Peter Larsson-Green J nk ping University Spring 2020

  2. PERMISSIONS Some features are protected by permissions. Before we can use the feature, we need the user's permission to use it. Categories of permissions: Normal permissions Dangerous permissions Permissions are grouped. File System GPS Camera Bluetooth Internet

  3. OBTAINING PERMISSION The old way: 1. List required permission in AndroidManifest.xml. 2. User grants the application these permission at installation time. User needs to grant permission to use optional features <manifest package="se.ju.larpet.myapplication" xmlns:android="http://schemas.android.com/apk/res/android"> <uses-permission android:name="the.permission" /> <uses-permission android:name="the.other.permission" /> <application android:label="My Cool App">...</application> </manifest>

  4. OBTAINING PERMISSION The new way (Android 6, API level 23): 1. List required permission in AndroidManifest.xml. 2. User grants the application permissions at runtime. We developers need to write extra code to make this happen... We developers need to write extra code to handle the cases where we don't get the permissions... User only needs to grant permission for optional features if she uses them

  5. OBTAINING PERMISSION AT RUNTIME aFragment anActivity.requestPermissions( new String[]{"permission1", "permission2"}, 123 ActivityCompat.requestPermissions( ); theActivity, new String[]{"permission1", "permission2"}, 123 ); @Override public void onRequestPermissionsResult( int requestCode, String permissions[], int[] grantResults ){ // ... PackageManager.PERMISSION_GRANTED PackageManager.PERMISSION_DENIED }

  6. CHECKING PERMISSION AT RUNTIME int permStat = aContext.checkSelfPermission("the.permission"); if(permStat == PackageManager.PERMISSION_GRANTED){ // We already have the permission }else{ // We need to ask for the permission. } int permStat = ContextCompat.checkSelfPermission(aContext, "the.permission"); if(permStat == PackageManager.PERMISSION_GRANTED){ // We already have the permission }else{ // We need to ask for the permission. }

More Related Content