小编har*_*h J的帖子

如何在android中设置权限WRITE_SECURE_SETTINGS?

我正在尝试启用4.0以上的辅助功能服务设置,但它显示异常即,

引起:java.lang.SecurityException:权限拒绝:写入安全设置需要android.permission.WRITE_SECURE_SETTINGS

在Manifest中我已经声明了这样的权限.

<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
Run Code Online (Sandbox Code Playgroud)

但是在清单给出编译错误,即权限只是系统应用程序.所以我不知道如何解决这个问题.

提前致谢

这是我的示例代码

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);
            }
        }
Run Code Online (Sandbox Code Playgroud)

android android-service

11
推荐指数
1
解决办法
5万
查看次数

标签 统计

android ×1

android-service ×1