3

Do you have any idea how can we configure and turn on the wi-fi hotspot using the command line (ADB console)?

0
8

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

6
  • For android 5.0+ if this is not working then add another one more keyevent 20. Credits: Kristopher Apr 26 '17 at 10:53
  • @xavier_fakerat where does the additional keyevent 20 go? Should it be 20 20 66 or 20 66 20?
    – Andrew
    Dec 20 '17 at 16:58
  • @Andrew 20, 20 and 66 i.e down, down, enter Dec 20 '17 at 18:00
  • 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/.TetherSettings then adb shell input keyevent 66.
    – Andrew
    Dec 21 '17 at 14:27
  • 1
    If 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 -S in first command. That is : adb shell am start -S com.android.settings/.TetherSettings
    – Efe
    Aug 6 at 12:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.