我们目前正在开发一个应用程序,我们想在其中更改一些系统设置,当然需要用户许可。 android文档说要做到这一点,你必须添加以下权限:
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
此外,必须明确要求用户启用此权限。摘自 https://developer.android.com/reference/android/Manifest.permission#WRITE_SETTINGS说: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
Settings.ACTION_MANAGE_WRITE_SETTINGS
. The app can check whether it has this authorization by callingSettings.System.canWrite()
.
到目前为止,一切都很清楚。但是,当权限被添加到 AndroidManifest.xml 文件时,Android Studio 会提示“权限只授予系统应用程序”。现在,这令人困惑,因为我没有找到任何说明它确实只授予系统应用程序的文档。
所以,我想问一下是否有人遇到过这个问题,是否有某种文档可以详细解释这个问题?还是我只是错过了什么?
最佳答案
如用户 passsy 所述在堆栈溢出 question由 Brian 提供, android.permission.WRITE_SETTINGS
有一个 android:protectionLevel
的 "signature"
,这使得自 API 级别 23 起该权限无法在用户应用程序中使用。
见 https://developer.android.com/guide/topics/manifest/permission-element#plevel用于权限保护级别的描述。
关于android - android.permission.WRITE_SETTINGS 是否只授予系统应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63192108/