Do you have any idea how can we configure and turn on the wi-fi hotspot using the command line (ADB console)?
2 Answers
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

- 10,065
- 6
- 41
- 101
EDIT: To start/stop Hotspot through adb with the help of Automate, all what you'd need to do is to create a flow in Automate implementing the logic through simple block programming, copy its URI and the use broadcast it through a shell using Activity Manager
adb shell am broadcast -a com.llamalab.automate.intent.action.START_FLOW \ -d FLOW_URI_YOU_COPIED_HERE \ -n com.llamalab.automate/.StartServiceReceiver
This will immediately execute whatever logic you have created in the flow. In our case, that was enabling Hotspot. You could also pass on extras to the flow to have more functionality
Example for sending over extra information while starting the flow
adb shell am broadcast -a com.llamalab.automate.intent.action.START_FLOW \ -d FLOW_URI_YOU_COPIED \ -n com.llamalab.automate/.StartServiceReceiver \ -e key1 value1 \ -e key2 value2
The information sent then gets captured in the Payload section of the flow beginning
Searched up the whole internet couldn't find out anything BUT then I remembered about one POWERFUL app called Automate.
Using this app, you could create a complex set of instructions to be executed in your phone by something called flows.
The app has some really beautiful UI.
Here's a video demonstrating some really simple things you could do:
https://www.youtube.com/watch?v=i53Yd30TFrU
Simply speaking, you could access ALL sorts of Android APIs that would be extremely complicated to access otherwise through ADB alone. It's a universal solution for all phones to this hotspot problem and countless others.
It also has a vibrant community tab through which you could access the millions of flows created by other people.
The app is freemium, doesn't contain ads whatsoever. The only limitation is that you could run 30 blocks simultaneously at a time.
How to start/stop an Automate flow through ADB:
https://groups.google.com/g/automate-user/c/IPmrJ4HjXwk?pli=1
https://www.reddit.com/r/AutomateUser/comments/qqmpms/how_can_i_start_a_flow_via_adb/
App Link
https://play.google.com/store/apps/details?id=com.llamalab.automate
App Documentation
https://llamalab.com/automate/

- 11
- 3
keyevent 20
. Credits: Kristopher – xavier_fakerat Apr 26 '17 at 10:53keyevent 20
go? Should it be 20 20 66 or 20 66 20? – Andrew Dec 20 '17 at 16:5820
,20
and66
i.e down, down, enter – xavier_fakerat Dec 20 '17 at 18:00adb shell am start -n com.android.settings/.TetherSettings
thenadb shell input keyevent 66
. – Andrew Dec 21 '17 at 14:27Warning: Activity not started, intent has been delivered to currently running top-most instance.
I can't verify if that means it's not working or not, as I have a dead screen. Is this normal? I'm on Android 9.0. – Arctiic Jul 28 '19 at 03:37-n
, you can use-S
in first command. That is :adb shell am start -S com.android.settings/.TetherSettings
– Efe Aug 06 '21 at 12:14input keyevent 20
its fine but after that I dont needenter
but needkeyevent to simulated toggle on off button
what would that be .Android 10 ver 29
– user1874594 Aug 05 '23 at 02:20