android.permission.WRITE_SETTINGS cant use in manifest

淺唱寂寞╮ 提交于 2019-12-11 00:56:19

问题


Can't use android.permission.WRITE_SETTINGS in android manifest. im trying to turn on airplane mode by programatticaly and I can't add this permission in manifest.

<uses-permission android:name="android.permission.WRITE_SETTINGS" />

回答1:


The Android docs says:

Note: If the app targets API level 23 or higher, the app user must explicitly grant this permission to the app through a permission management screen. The app requests the user's approval by sending an intent with action ACTION_MANAGE_WRITE_SETTINGS. The app can check whether it has this authorization by calling Settings.System.canWrite().

So you have to request the user's approval explicitly by sending an intent with action ACTION_MANAGE_WRITE_SETTINGS.




回答2:


What is the error message that you are getting? Is the app crashing when you try to open it or set the airplane settings? If you are targetting >API 23, you need to explicitly ask for permissions during runtime, this is a change from earlier versions when the permission was granted once at install time.

This link talks abou this: https://developer.android.com/reference/android/Manifest.permission.html#WRITE_SETTINGS



来源:https://stackoverflow.com/questions/50959842/android-permission-write-settings-cant-use-in-manifest

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