2012-06-23 38 views

回答

1

我想沒有選項的代碼

正確啓用網絡共享。

任何人都可以請您告訴我如何通過代碼手動調用「無線和網絡 - 共享和便攜式熱點」意圖來啓用共享。

目前沒有文檔記錄和支持的Intent操作在Settings應用程序中顯示此特定屏幕。

+0

謝謝。但是有沒有其他方法可以部分實現這一目標? –

2

在4.1.2中測試,也許應該在4.0中工作。

Intent tetherSettings = new Intent(); 
tetherSettings.setClassName("com.android.settings", "com.android.settings.TetherSettings"); 
startActivity(tetherSettings); 
+0

做同樣事情的另一種方法[via:http://forum.xda-developers.com/showthread.php?t=690616] //加載系鏈設置對話框 Intent intent = new Intent(); intent.setAction(Intent.ACTION_MAIN);組件名稱com = new ComponentName(「com.android.settings」,「com.android.settings.TetherSettings」); intent.setComponent(com); startActivity(intent); –

-2

此代碼只是啓動共享設置並單擊USB共享複選框(如果關閉,則反之亦然)。

adb shell am start -n com.android.settings/.TetherSettings && adb shell input keyevent 20 && adb shell input keyevent 20 && adb shell input keyevent KEYCODE_ENTER && sleep 2 && adb shell input keyevent 4 
相關問題