以编程方式打开“未知来源"设置 [英] Turn on Unknown Sources setting programmatically

查看:102
本文介绍了以编程方式打开“未知来源"设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这篇关于以编程方式打开“未知来源"设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆