Many Android power users love ADB because it lets you run low‑level commands without opening a terminal on the device. The downside is that ADB is usually a manual, one‑off tool – you connect a PC, type a command, then disconnect. Tasker can bridge that gap by triggering ADB commands from the phone itself, turning a series of keystrokes into a hands‑free routine.
Run Shell action with Use Root unchecked.adb devices
You should see your device listed. Then enable TCP/IP mode:
adb tcpip 5555
Disconnect the USB cable. Your phone is now listening for ADB connections on port 5555.192.168.1.42).adb installed via Termux), test the connection:
adb connect 192.168.1.42:5555
You should see “connected to 192.168.1.42:5555”. If you get “unable to connect”, double‑check the IP and that the phone’s firewall isn’t blocking port 5555.Tasker cannot call adb directly because the binary lives on a PC. The workaround is to install the ADB client locally via Termux, then let Tasker invoke it through a Run Shell action.
pkg update && pkg upgrade -y
pkg install android-tools
This places the adb executable in $PREFIX/bin.termux-setup-storage
Accept the Android storage permission dialog.adb devices
You should see a line like 127.0.0.1:5555 device. If not, run adb start-server first.Tasker’s Run Shell action can execute any command that the app’s process is allowed to run. Because we are not using root, the command must be executable by the regular app user. The ADB binary installed in Termux is accessible to other apps only if we place a symbolic link in a location that Tasker can read, such as /data/local/tmp. Android blocks write access to that folder for non‑system apps, but we can use the run-as trick on a debug build, or simply copy the binary to the app’s private files directory and reference it via its full path.
termux-exec wrapper which forwards the command to the Termux environment. Tasker will invoke termux-exec with the desired ADB arguments.adb:
cat > $HOME/adb-wrapper.sh <<'EOF'
#!/data/data/com.termux/files/usr/bin/sh
exec /data/data/com.termux/files/usr/bin/adb "$@"
EOF
chmod +x $HOME/adb-wrapper.sh
mv $HOME/adb-wrapper.sh /sdcard/adb-wrapper.sh
Tasker can read files from /sdcard without extra permissions.Time later).Command field, type the full path to the wrapper and the ADB arguments you need, for example:
/sdcard/adb-wrapper.sh shell settings put global airplane_mode_on 1
Below are three common automation scenarios that illustrate the power of combining ADB with Tasker.
22:00 as the start time.
Command field, use:
/sdcard/adb-wrapper.sh shell settings put global airplane_mode_on 1 && /sdcard/adb-wrapper.sh shell am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true
The first part updates the system setting; the second part broadcasts the change so the UI updates immediately.
07:00 that runs the same command with 0 (disable) and false.
When the time arrives, Tasker runs the command without any user interaction, effectively automating a “Do Not Disturb” window.
%FREE_SPACE (Tasker can compute free space via Java Function or a small shell script). Set the condition %FREE_SPACE < 500 (megabytes)./sdcard/adb-wrapper.sh shell pm clear com.example.app
Replace com.example.app with the target package name.
%CHARGING variable.
This automation helps prevent “low storage” warnings by regularly cleaning cache of a heavy‑use app (e.g., a podcast player).
Sometimes you need to grant a runtime permission before an app starts, otherwise the first launch shows a dialog that blocks automation. ADB can grant permissions silently.
com.whatsapp)./sdcard/adb-wrapper.sh shell pm grant com.whatsapp android.permission.READ_CONTACTS
/sdcard/adb-wrapper.sh shell monkey -p com.whatsapp -c android.intent.category.LAUNCHER 1
Now, whenever you tap the WhatsApp icon, Tasker first grants the contacts permission (if not already granted) and then opens the app, removing the permission dialog.
ADB to confirm the command executed without error.Airplane mode set: %taskout.chmod +x /sdcard/adb-wrapper.sh) and that the path is correct. Tasker’s Run Shell uses the app’s default working directory, so absolute paths are safest.settings put commands work because they are exposed via the ADB daemon. If a particular command fails, check whether it requires root by running it manually in Termux first.adb devices every 10 minutes.Run Shell action’s Timeout is set high enough (default 10 seconds). Complex commands like pm clear may need 20 seconds.&& to ensure the second runs only if the first succeeds. Example:
/sdcard/adb-wrapper.sh shell settings put system screen_off_timeout 60000 && /sdcard/adb-wrapper.sh shell input keyevent 26
This sets a 1‑minute screen timeout then immediately turns the screen off.%WIFI_STATE:
/sdcard/adb-wrapper.sh shell svc wifi %WIFI_STATE
Set %WIFI_STATE to enable or disable earlier in the task.Do Not Disturb actions to create a “night mode” profile that silences notifications, lowers screen brightness, and disables Bluetooth—all via ADB commands for deeper control.adb -s 192.168.1.55:5555 shell <command>
Create separate wrapper scripts for each device and call the appropriate one from Tasker.pm uninstall --user 0 command via this automation unless you are absolutely sure you want to remove a system app for the current user. The operation is reversible only by flashing a factory image.airplane_mode_on) can interfere with ongoing calls or data transfers. Schedule such changes during periods of low activity./data/data/com.termux/files/home) and granting Tasker the READ_EXTERNAL_STORAGE permission to access it via a content URI.By installing Termux, exposing the ADB client locally, and using Tasker’s Run Shell action, you gain the ability to run virtually any ADB command without ever touching a PC again. The workflow is fully reversible: disable the “Wireless debugging” toggle or delete the wrapper script to stop automation instantly.
Experiment with the examples above, then adapt them to your own routine – whether it’s silencing the device at bedtime, clearing caches when storage is low, or granting permissions to newly installed apps. The combination of ADB’s power and Tasker’s flexibility turns a static command line into a living, context‑aware assistant on your Android phone.









