I am developing an application for Android 3.0 and above. I want to communicate to a PC by tethering.
How do I call the "Wireless and networks-Tethering and portable hotspot Intent" by code to enable the tethering manually?
I am developing an application for Android 3.0 and above. I want to communicate to a PC by tethering.
How do I call the "Wireless and networks-Tethering and portable hotspot Intent" by code to enable the tethering manually?
Tested in 4.1.2, perhaps should work in 4.0 also.
Intent tetherSettings = new Intent();
tetherSettings.setClassName("com.android.settings", "com.android.settings.TetherSettings");
startActivity(tetherSettings);
I guess there is no option to enable the tethering by the code
Correct.
And any one could you please tell me how to call the "Wireless and networks-Tethering and portable hotspot" intent by code to enable the tethering manually.
There is no documented and supported Intent
action to bring up this specific screen in the Settings app at this time.
this code just starts the tethering settings and clicks on the USB tethering checkbox (setting it on if it's off and vice versa).
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