• android user版本默认开启调试模式


    由于项目需要,需要发布版本默认开启调试模式,修改方式如下:

    1.开启开发者模式

    context.getSharedPreferences(DevelopmentSettings.PREF_FILE,Context.MODE_PRIVATE).edit().putBoolean(

                                        DevelopmentSettings.PREF_SHOW, true).apply();

    2.勾选USB调试

       Settings.Global.putInt(context.getContentResolver(),  Settings.Global.ADB_ENABLED, 1);

    3.去掉USB插入时的授权提示

     修改frameworksasepackagesSystemUIsrccomandroidsystemuiusbUsbDebuggingActivity.java的如下内容:

            @Override
            public void onReceive(Context content, Intent intent) {
                String action = intent.getAction();
                if (!UsbManager.ACTION_USB_STATE.equals(action)) {
                    return;
                }
                /*boolean connected = intent.getBooleanExtra(UsbManager.USB_CONNECTED, false);
                if (!connected) {
                    mActivity.finish();
                }*/
    	    boolean connected  = false;   //给connect赋值,关掉UI
                if (!connected) {
                    mActivity.finish();
                }
                try {
    	    IBinder b = ServiceManager.getService(USB_SERVICE);     
    	    IUsbManager service = IUsbManager.Stub.asInterface(b);
    	    service.allowUsbDebugging(true, mKey);
                } catch (Exception e) {
    	    Log.e(TAG, "Unable to notify Usb service", e);
                }
            }                
    
  • 相关阅读:
    ajax_基础1
    省市数据库脚本TblArea.
    c#中怎么使用dos命
    Lambda表达式
    面试收录
    .Net牛逼程序猿要懂得
    Web.config 配置文件
    sql 查询所有数据库、表名、表字段总结
    Json在net与页面之间的传递
    『转』SAP统驭科目解释
  • 原文地址:https://www.cnblogs.com/suxiaoqi/p/4882297.html
Copyright © 2020-2023  润新知