enable/disable airplane mode using adb command on kotlin language

1.3k views Asked by At
adb shell settings put global airplane_mode_on 1
adb shell su -c am broadcast -a android.intent.action.AIRPLANE_MODE

It works if done through the adb program. But if you try to execute in your program, nothing happens. Root are present on the phone, also when the function is executed, a toast pops up stating that superuser rights have been granted.

Runtime.getRuntime().exec("su -c 'settings put global airplane_mode_on 1'");
Runtime.getRuntime().exec("su -c 'am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true'");

what am I doing wrong?

1

There are 1 answers

1
ARCHER On

To enable/disable the Airplane mode,use the following adb commands:

adb shell am start -a android.settings.AIRPLANE_MODE_SETTINGS

#toggle/opposite

adb shell input keyevent 19 & adb shell input keyevent 19 & adb shell input keyevent 23