Android开发:设置USB tethering 和USB debugging
16lz
2022-06-17
设置 USB tethering
设置 USB debugging
- public void setUSBTethering(boolean enabled){
- ConnectivityManager cm =
- (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
- if (cm.setUsbTethering(enabled) != ConnectivityManager.TETHER_ERROR_NO_ERROR ){
- System. out.println("usb tethering set failed !" );
- }
- }
- public void enableUSBDebugging()
- int adbEnabled=0;
- try {
- adbEnabled = Settings.Secure. getInt(getContentResolver(), Settings.Secure.ADB_ENABLED );
- } catch (SettingNotFoundException e) {
- e.printStackTrace();
- }
- if(adbEnabled != 1){
- Settings.Secure. putInt(getContentResolver(),Settings.Secure. ADB_ENABLED, 1);
- }
更多相关文章
- android Textview颜色渐变
- Android(安卓)中设置全屏的方法
- Android(安卓)设置View背景图网络url
- 第一章:初入Android大门(通过Button设置TextView颜色)
- Android使用继承View类来绘图
- android设置字符串到剪贴板
- Android(安卓)动态设置全屏,退出全屏
- android调用NotificationManager.notify无效,通知栏不显示
- android edittxet 设置可点击不可编辑状态