Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Explore Marshmallow : Android App Permission

Explore Marshmallow : Android App Permission

Android 6.0 "Marshmallow" is the latest version of the Android mobile operating system. It comes up with some noticeable features like new permission architecture, a new power management system, native support for fingerprint etc.

In this event, participants will learn What is the architecture of new permission model. How to ask for runtime permission to the user.

Currently, Android apps require you to grant access to phone or features before you install, like storage, images, contacts, location etc. With Android Marshmallow’s, new App Permissions functionality is totally changed and apps need to ask for permission when it needs in the app.

Chintan Rathod

November 01, 2015
Tweet

More Decks by Chintan Rathod

Other Decks in Technology

Transcript

  1. How permission works? Install an App System check permission in

    Androidmanifest.xml System ask user for approval User approve ? System grants all permission System denies all permissions System cancel installation System check permission in Androidmanifest.xml
  2. • So, we do trust on them • Also granting

    permission which are not necessary but there is no other way around What we are doing?
  3. • Each app will run in limited sandbox • Explicit

    permission request is required for outside resource use • User may grant or deny runtime permission What’s new?
  4. Level of protections Normal Permission It cover areas where your

    app needs to access data or resources outside the app's sandbox, but where there's very little risk to the user's privacy or the operation of other apps Dangerous Permission It cover areas where the app wants data or resources that involve the user's private information, or could potentially affect the user's stored data or the operation of other apps.
  5. The following permissions are classified as ROTECTION_NORMAL Normal Permission ACCESS_LOCATION_EXTRA_COMMANDS

    ACCESS_NETWORK_STATE ACCESS_NOTIFICATION_POLICY ACCESS_WIFI_STATE BLUETOOTHBROADCAST_STICKY CHANGE_NETWORK_STATE CHANGE_WIFI_MULTICAST_STATE CHANGE_WIFI_STATE DISABLE_KEYGUARD EXPAND_STATUS_BAR FLASHLIGHT GET_PACKAGE_SIZE INTERNET KILL_BACKGROUND_PROCESSES NFC READ_SYNC_STATS RECEIVE_BOOT_COMPLETED REORDER_TASKS REQUEST_INSTALL_PACKAGES SET_TIME_ZONE SET_WALLPAPER SET_WALLPAPER_HINTS USE_FINGERPRINT VIBRATE WAKE_LOCK WRITE_SYNC_SETTINGS SET_ALARM INSTALL_SHORTCUT UNINSTALL_SHORTCUT
  6. Ask for permission : SDK >= 23 Example checkSelfPermission(Manifest.permission. READ_CONTACTS

    ) Syntax checkSelfPermission(Manifest.permission.PERMISSION_NA ME )
  7. Ask for permission : SDK >= 14 Example ActivityCompact.checkSelfPermission(YourActivity.this, Manifest.permission.

    READ_CONTACTS ) Syntax ActivityCompact.checkSelfPermission(Context, Manifest.permission.PERMISSION_NAME )
  8. Is request already granted? if(hasCameraPermission != PackageManager.PERMISSION_GRANTED ) { ActivityCompat.requestPermissions(

    MainActivity.this, new String[]{Manifest.permission.READ_CALL_LOG}, READ_CALL_LOG_REQUEST_CODE); } To handle result … implements ActivityCompat.OnRequestPermissionsResultCallback
  9. is request granted? @Override public void onRequestPermissionsResult(int requestCode, String[] permissions,

    int[] grantResults) { switch (requestCode){ case READ_CONTACT_REQUEST_CODE: if (grantResults.length >= 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { //Permission Granted } else { //Permission Denied } break; case OTHER_CASE: break; } }