如何在Android中设置权限WRITE_SECURE_SETTINGS? [英] How to set the Permission WRITE_SECURE_SETTINGS in android?
问题描述
我正在尝试启用4.0以上的辅助功能设置,但它显示了异常,即
I am trying to enable the Accessibility Service Settings above 4.0 but It is showing an Exception i.e.,
原因:java.lang.SecurityException:权限被拒绝:写入安全设置需要android.permission.WRITE_SECURE_SETTINGS
Caused by: java.lang.SecurityException: Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS
在清单中,我已经这样声明了此权限.
In Manifest I have Declared This permission like this.
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
但是在清单中给出了编译错误,即,权限仅是System Apps. 因此,我不了解如何解决此问题.
But in manifest giving compilation Error i.e., Permission is only System Apps. So i am not Understanding how to resolve this issue.
预先感谢
这是我的示例代码
if (Settings.Secure.getString(getContentResolver(),
Settings.Secure.ACCESSIBILITY_ENABLED).contains("1")) {
if (Settings.Secure.getString(getContentResolver(),
Settings.Secure.ACCESSIBILITY_ENABLED).contains("1")) {
System.out.println("Putting the Value to Enable..");
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_ENABLED, 0);
} else {
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.TOUCH_EXPLORATION_ENABLED, 1);
}
}
推荐答案
WRITE_SECURE_SETTINGS对应用程序不可用.系统/固件之外的任何应用都无法获得该许可.
WRITE_SECURE_SETTINGS is not available to applications. No app outside of the system/firmware can get that permisssion.
请检查此答案
这篇关于如何在Android中设置权限WRITE_SECURE_SETTINGS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!