I've looked all over and I haven't found a concrete answer to this question. I'm hoping to find a way to toggle airplane mode from ADB that doesn't involve the GUI in any way. I've found and used the method that calls up the menu and then using keyevents turns airplane mode on, but due to needing to account for possible changes in UI layout, this method is only a temporary solution.
I'm beginning to think there isn't a way to just toggle airplane mode on or off via intent, but if you have any information, I'd greatly appreciate it.
Boot your phone into Android, then connect it to your desktop computer with a USB cable. On your computer, launch the Command Prompt and change the directory to point to the platform-tools folder. Type adb devices and hit Enter.
YES!.. Few years ago even I was in search of such an app which would help me schedule Airplane mode toggle on my smartphone. Then I found this app - MacroDroid - Device Automation - Android Apps on Google Play . You can automate your phone to a whole different level using this app.
First, I would never rely on solutions which are blindly navigating through the UI as suggested in most answers here. More in a note below.
I like the G murali's first answer which suggests the following to enable the airplane mode:
adb shell settings put global airplane_mode_on 1
Unfortunately, it doesn't work. It just changes the state of the Airplane mode icon, but all radios are still active.
It's missing one very important part, which is broadcasting the intent right after the setting has been changed to inform applications that the Airplane mode state has changed.
To enable the Airplane mode use the following commands:
adb shell settings put global airplane_mode_on 1 adb shell am broadcast -a android.intent.action.AIRPLANE_MODE
To disable the Airplane mode, you have to chnage the setting to 0 and broadcast the intent again:
adb shell settings put global airplane_mode_on 0 adb shell am broadcast -a android.intent.action.AIRPLANE_MODE
It's tested and working on Android 6.
Many answers suggest to use an activity to open the Airplane mode settings and then simulate some key presses to navigate through the UI. I don't recommend to rely on that. There may be just a short lag on the device and keys will be pressed before the Settings dialog is opened or for example some unexpected dialog will appear meanwhile. In both cases the key presses will cause something unintended, possibly harmful.
Also the UI may be different on devices of various brands, models, Android versions, etc. I have tested it on Samsung Galaxy S4 (Android 6.0.1) and it didn't work there. It may be by a difference between the Samsung's and the default UI.
The settings manipulation method should be perfectly safe.
For newer android this en/disables wifi. Not quite your task, but i would've been happy to find it here:
adb shell svc wifi disable
or
adb shell svc wifi enable
Credit goes to this answer: https://stackoverflow.com/a/27228962/1021872
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With