Request permission on Android M only when targeting lower API

淺唱寂寞╮ 提交于 2019-12-07 04:10:31

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/32738651/request-permission-on-android-m-only-when-targeting-lower-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!