zoukankan      html  css  js  c++  java
  • 用代码的方式打开“允许安装来自未知来源的应用”

    在手机上,当然可以通过系统的设置来将其打开,但是如果某个设备上没有该设置呢?

    以下的代码需要平台的签名或者作为系统应用来运行才行(adb push <your apk files> /system/app/<your apk files>) ---当然

    需要先运行 adb root

    1.需要添加的权限

            <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
        <uses-permission android:name="android.permission.WRITE_SETTINGS"/>
        <uses-permission android:name="android.permission.READ_SECURE_SETTINGS"/>
        <uses-permission android:name="android.permission.READ_SETTINGS"/> 

    2.

    import android.provider.Settings;
    import android.content.ContentValues;

         ContentValues values = new ContentValues(); values.put("value", 1);
        Cursor cursor = null;
    try{ int value = 0; cursor = getContentResolver().query(Settings.Secure.CONTENT_URI,
              new String[] { "value",}, "name=?", new String[] {Settings.Secure.INSTALL_NON_MARKET_APPS}, null); if(cursor != null && cursor.moveToNext()){ value = cursor.getInt(cursor.getColumnIndex("value")); }
    if(cursor != null){
              cursor.close();
             cursor = null;
           }
    if(0 == value){ int i = getContentResolver().update(Settings.Secure.CONTENT_URI, values,"name=?", new String[] {Settings.Secure.INSTALL_NON_MARKET_APPS} ); if(i > 0){ Log.e("", "success"); }else{ Log.e("", "fail"); } } }catch (Exception e) { e.printStackTrace(); }finally{
    if(cursor != null){
              cursor.close();
             cursor = null;
           }
         }
  • 相关阅读:
    P2P技术简介(包括BT软件的分析)(转)
    为什么BT网络中迅雷的速度会这么快,比其它BT软件快
    迅雷中几个概念
    BT中的磁力链接(转)
    eclipse代码不能自动提示的问题解决
    eclipse不会自动编译的问题解决
    BT网络中DHT和UPnp的解释(转)
    BT服务器的搭建(tracker-P2P服务器架设)(转)
    BT原理分析(转)
    BT种子文件文件结构分析(转)
  • 原文地址:https://www.cnblogs.com/mengshu-lbq/p/3214737.html
Copyright © 2011-2022 走看看