以编程方式打开“未知来源"设置

以编程方式打开“未知来源

问题描述:

我想以编程方式打开无根设备上的未知源"设置.我已经检查了以下代码:

I want to turn on Unknown Sources setting programmatically on non rooted device. I have checked with this code:

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.

我已经获得了设备管理员的许可.

I have made this application with device admin permission.

但是在执行时,它说权限被拒绝:写入安全设置需要我已经给出的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.

除非拥有与固件签名相同的签名密钥进行了签名,或者您已安装在系统分区上(例如,由具有root用户权限的设备用户使用),否则无法持有该权限.

You cannot hold that permission, unless you are signed by the same signing key that signed the firmware or if you were installed on the system partition (e.g., by a rooted device user).

我已经获得了设备管理员的许可.

I have made this application with device admin permission.

这与以编程方式修改安全设置无关.

That has nothing to do with modifying secure settings programmatically.