Do you have any idea how can we configure and turn on the wi-fi hotspot using the command line (ADB console)?
You could try this:
adb shell am start -n com.android.settings/.TetherSettings adb shell input keyevent 20 adb shell input keyevent 66
The first command opens the Settings page for Tethering and Hotspot while the latter simulate key presses: Down and Enter respectively.
Note: For different Android versions you may have to adjust the simulation of key presses depending on where the hotspot setting is located under settings.
Special Credits : Firelord and Kristopher
Firelord originally posted this as a comment, so I put this as an answer as comments are easily deleted or difficult to find
For android 5.0+ if this is not working then add another one more
keyevent 20. Credits: Kristopher Apr 26, 2017 at 10:53
@xavier_fakerat where does the additional
keyevent 20go? Should it be 20 20 66 or 20 66 20?– AndrewDec 20, 2017 at 16:58
1@xavier_fakerat Thank you! My phone actually has cyanogenmod on it, and enabling the hotspot is the first option in the settings, so all I needed to do was enter
adb shell am start -n com.android.settings/.TetherSettingsthen
adb shell input keyevent 66.– AndrewDec 21, 2017 at 14:27
1@Arctiic This is pretty normal. It is not an error message, it is a warning sort of, the system is trying to tell you that you already have the same instance of the activity thus the system tells you that it is not going to kill and restart it, but bring the activity of your already running task into the foreground. Depending on the actual input events you should get the hotspot up with no issues ;) Jul 28, 2019 at 19:33
2If you do this repeatedly, you need to close target app before starting activity, otherwise, activity will stay open and key events will target other controls. Hence, instead of
-n, you can use
-Sin first command. That is :
adb shell am start -S com.android.settings/.TetherSettings– EfeAug 6, 2021 at 12:14