android user版本默认开启调试模式
生活随笔
收集整理的這篇文章主要介紹了
android user版本默认开启调试模式
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
由于項目需要,需要發(fā)布版本默認(rèn)開啟調(diào)試模式,修改方式如下:
1.開啟開發(fā)者模式
context.getSharedPreferences(DevelopmentSettings.PREF_FILE,Context.MODE_PRIVATE).edit().putBoolean(
??????????????????????????????????? DevelopmentSettings.PREF_SHOW, true).apply();
2.勾選USB調(diào)試
???Settings.Global.putInt(context.getContentResolver(),??Settings.Global.ADB_ENABLED, 1);
3.去掉USB插入時的授權(quán)提示
修改frameworks\base\packages\SystemUI\src\com\android\systemui\usb\UsbDebuggingActivity.java的如下內(nèi)容:
?
@Overridepublic 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賦值,關(guān)掉UIif (!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);}}?
轉(zhuǎn)載于:https://www.cnblogs.com/suxiaoqi/p/4882297.html
總結(jié)
以上是生活随笔為你收集整理的android user版本默认开启调试模式的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 第七章 异常总结
- 下一篇: 内存对齐分配策略(含位域模式)