0

I am trying to follow the guide from google to implements permissions in my app to work with Android M. ( http://developer.android.com/training/permissions/requesting.html ) However, I am NOT able to check the <uses-permission>, my questions is: should I migrate the <uses-permission> into <permission> ?

int permissionCheck = ContextCompat.checkSelfPermission(thisActivity,
        Manifest.permission.WRITE_CALENDAR);

My manifest permissions are this:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />

<permission android:name="android.permission.MEDIA_CONTENT_CONTROL" />

To be more explicit I am able to call only this method:

        int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.MEDIA_CONTENT_CONTROL);

I can't check the internet, wake_lock or other <uses-permission>

Marian Pavel
  • 2,726
  • 8
  • 29
  • 65
  • "However, I am NOT able to check the " -- please explain what you mean by this. "should I migrate the into ?" -- no. Get rid of `` (as that is not your permission to define, since [it already exists](http://developer.android.com/reference/android/Manifest.permission.html#MEDIA_CONTENT_CONTROL)). At most, have a `` for that. – CommonsWare Mar 07 '16 at 13:40
  • I need to use ` – Marian Pavel Mar 07 '16 at 13:42
  • Try this it may be work http://stackoverflow.com/a/41221852/5488468 – Bipin Bharti Jan 03 '17 at 11:08

1 Answers1

2

I can't check the internet, wake_lock or other

That is because those are not dangerous permissions. The dangerous permissions, for Android 6.0, are:

  • ACCESS_COARSE_LOCATION
  • ACCESS_FINE_LOCATION
  • ADD_VOICEMAIL
  • BODY_SENSORS
  • CALL_PHONE
  • CAMERA
  • GET_ACCOUNTS
  • PROCESS_OUTGOING_CALLS
  • READ_CALENDAR
  • READ_CALL_LOG
  • READ_CELL_BROADCASTS
  • READ_CONTACTS
  • READ_EXTERNAL_STORAGE
  • READ_PHONE_STATE
  • READ_SMS
  • RECEIVE_MMS
  • RECEIVE_SMS
  • RECEIVE_WAP_PUSH
  • RECORD_AUDIO
  • SEND_SMS
  • USE_SIP
  • WRITE_CALENDAR
  • WRITE_CALL_LOG
  • WRITE_CONTACTS
  • WRITE_EXTERNAL_STORAGE

You get normal permissions, like WAKE_LOCK and INTERNET, automatically. MEDIA_CONTENT_CONTROL is a signature-level permission; ordinary Android apps cannot hold it.

I need to use <uses-permission-sdk-23> for marshmallow ?

That is for permissions that you only want to request on API Level 23+ devices, but want to skip on older devices.

should I migrate the <uses-permission> into <permission> ?

No. The framework defines the framework permissions. You would use <permission> only if you are defining some custom permission for use by third-party clients of your app's API.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Dangerous permissions are declared in manifest in the same way as normal permissions ? – Marian Pavel Mar 07 '16 at 14:02
  • @PavelMarian: In terms of ``, yes. Whoever *defines* the permission, via the `` element, will have an `android:protectionLevel` attribute with `normal`, `dangerous`, `signature`, etc. Permissions that you see in the Android SDK are defined by the framework. – CommonsWare Mar 07 '16 at 14:09