我想在非 root 设备上以编程方式打开未知来源设置。我已经检查过这段代码:
boolean success;
int result = Settings.Secure.getInt(getContentResolver(),
Settings.Secure.INSTALL_NON_MARKET_APPS, 0);
if (result == 0) {
success = Settings.Secure.putString(getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS, "1");
}
并具有以下权限:
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
但在执行时,它显示 permission denied: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS
我已经给出了。
我已使用设备管理员权限制作此应用程序。
最佳答案
but on executing, it says permission denied: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS which I already have given.
您不能拥有该权限,除非您使用与固件签名相同的签名 key 进行签名,或者如果您安装在系统分区上(例如,由获得 root 权限的设备用户)。
I have made this application with device admin permission.
这与以编程方式修改安全设置无关。
关于android - 以编程方式打开未知来源设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19026554/