当前位置:   article > 正文

允许或拒绝安装未知来源_seuic允许安装密码

seuic允许安装密码

在这个/packages/SettingsProvider/res/values/defaults.xml
 <bool name="def_bluetooth_on">false</bool>
     <bool name="def_wifi_display_on">false</bool>
-    <bool name="def_install_non_market_apps">false</bool>
+    <bool name="def_install_non_market_apps">true</bool>
     <bool name="def_package_verifier_enable">true</bool>
     <!-- Comma-separated list of location providers.
          Network location is off by default because it requires
中将
def_install_non_market_apps的值置为true即可





代码中:


方法

public static boolean EnableOrDisableUnknownSource(Context context, boolean isOpen){
    boolean success = false;
    int result = Settings.Secure.getInt(context.getContentResolver(),
            Settings.Secure.INSTALL_NON_MARKET_APPS, 0);
    LogUtils.d("enable install unknown source result : "+result);
    if (result == 0 && isOpen) {
        success = Settings.Secure.putString(context.getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS, "1");
    }else if(!isOpen){
        success = Settings.Secure.putString(context.getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS, "0");

    }
    LogUtils.d("enable install unknown source : "+success);
    return success;
}
 
 
添加权限:
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>




原文地址:

设置的源码及与未知来源相关的代码

https://blog.csdn.net/adayabetter/article/details/43407637



Android O安装未知来源

http://baijiahao.baidu.com/s?id=1577241378718915266&wfr=spider&for=pc


根据代码描述流程

https://blog.csdn.net/ounuo5280/article/details/50587752


Settings源码:
https://blog.csdn.net/adayabetter/article/details/43407637

Android O去除“允许未知来源”选项,需手动确认
http://baijiahao.baidu.com/s?id=1577241378718915266&wfr=spider&for=pc

第三方lib包
com.symbol.emdk.*; 的使用
https://bbs.csdn.net/topics/392347147

代码实现
https://stackoverflow.com/questions/19026554/turn-on-unknown-sources-setting-programatically?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa





2、需要注意的地方

在android8.0系统中,无法自动安装打开app,其他低于8.0的没问题。原因就是,8.0系统限制了未知来源的应用安装的权限。解决方案是,android8.0需要适配,先判断是否有权限,没有的话引导用户进行设置

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/153047
推荐阅读
相关标签
  

闽ICP备14008679号