打开不明来源编程设置 [英] Turn on Unknown Sources setting programatically

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

问题描述

我想打开不明来源的非根深蒂固的设备编程设定。我跟这个code检查:

 布尔成功;
INT结果= Settings.Secure.getInt(getContentResolver()
Settings.Secure.INSTALL_NON_MARKET_APPS,0);
如果(结果== 0){
    成功= Settings.Secure.putString(getContentResolver(),Settings.Secure.INSTALL_NON_MARKET_APPS,1);
}

和具有以下权限:

 <使用许可权的android:NAME =android.permission.WRITE_SETTINGS/>
<使用许可权的android:NAME =android.permission.WRITE_SECURE_SETTINGS/>

但执行时,它说许可被拒绝:写保护设置需要android.permission.WRITE_SECURE_SETTINGS 我已经给

我与设备管理权限此应用程序。


解决方案

  

但执行时,它说权限被拒绝:写保护设置的要求,我已经给android.permission.WRITE_SECURE_SETTINGS


您不能持有该权限,除非你是由签署的固件或相同的签名密钥签署的,如果你被安装在系统分区(例如,通过植根设备的用户)。


  

我与设备管理权限此应用程序。


这已经无关编程方式修改安全设置。

I want to turn on Unknown Sources setting programatically 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");    
}

and with following permissions:

<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="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.

解决方案

but on executing, it says permission denied: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS which I already have given.

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天全站免登陆