Android开发:设置USB tethering 和USB debugging


设置 USB tethering

 
  
  1. publicvoid setUSBTethering(boolean enabled){  

  2.    ConnectivityManager cm =  

  3.            (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);  

  4. if (cm.setUsbTethering(enabled) != ConnectivityManager.TETHER_ERROR_NO_ERROR ){  

  5.              System. out.println("usb tethering set failed !" );  

  6.        }  

  7. }

设置 USB debugging
 
  
  1. publicvoid enableUSBDebugging()  

  2. int adbEnabled=0;  

  3. try {  

  4.             adbEnabled = Settings.Secure. getInt(getContentResolver(), Settings.Secure.ADB_ENABLED );  

  5.      } catch (SettingNotFoundException e) {  

  6.             e.printStackTrace();  

  7.      }  

  8. if(adbEnabled != 1){  

  9.             Settings.Secure. putInt(getContentResolver(),Settings.Secure. ADB_ENABLED, 1);  

  10.      }  

本文出自 “whithin's” 博客,请务必保留此出处http://whithin.blog.51cto.com/690417/1076101


你可能感兴趣的:(android,设置,usb,usb,debugging,Tethering)