6

So in my app i would like to add an option to selectively add a permission (say, direct dial) when the user is on Android M but, at the same time, i would like to have that permission NOT showing as required in API 22 or lower simply because its not essential so i prefer not asking for it during install (so de facto making that feature available on M only).

So, i understand the new model of M is that it will allow optional permissions when user is on M and it will make those permissions mandatory when on lower APIs. So is there any known way to just remove those permissions on API lower than 23? Without having separate flavours / APK?

Maybe merging a manifest with just those lines when API is > 22 ? Or there is a cleaner solution?

FrankMonza
  • 2,024
  • 16
  • 26

1 Answers1

8

This is possible. When reading the documentation there is a special flag to indicate for M only.

Use

<uses-permission-sdk23>

to apply permission for Marshmallow devices only.

Thomas R.
  • 7,988
  • 3
  • 30
  • 39
  • And i DID read the docs, thanks for the quick answer, exactly what i was looking for. – FrankMonza Sep 23 '15 at 12:30
  • 1
    Note that you double-check this next week(?), after Android 6.0 ships "for realz". *Probably*, this element name will remain the same, since it is rather late in the process. However, having `m` references in things like manifest element names is rather odd, and so I wouldn't rule out the possibility that they make a late switch to something else (e.g., an `android:minSdkVersion` counterpart to `android:maxSdkVersion` already available on ``). – CommonsWare Sep 23 '15 at 12:33
  • @CommonsWare thanks for the heads up, will definitely do, important thing is that the feature is there so somehow it will be kept (i hope so), definitely a minSdkVersion attribute to the uses-permission tag would be much cleaner (or at least a tag) – FrankMonza Sep 23 '15 at 13:32
  • 3
    @CommonsWare updated the answer, they went for a , honestly quite ugly, but still does what i want – FrankMonza Oct 07 '15 at 09:36