ADB Commands for Android TV and Fire TV: Remote Keys, Apps and Power
ADB commands for Android TV, Google TV and Fire TV. D-pad and media keys, typing, opening apps and YouTube links, settings screens, sleep, wake and reboot.
These commands work on Android TV, Google TV and Fire TV once ADB is connected. If you have not connected yet, start with how to control an Android TV with ADB. Every command below is run from your computer. In ADBKit you can paste the part after adb shell into the Shell panel.
Remote control keys
adb shell input keyevent <KEY> presses one button. You can use the name or the number.
| Remote button | Key name | Code |
|---|---|---|
| Up / Down | KEYCODE_DPAD_UP / KEYCODE_DPAD_DOWN | 19 / 20 |
| Left / Right | KEYCODE_DPAD_LEFT / KEYCODE_DPAD_RIGHT | 21 / 22 |
| OK (select) | KEYCODE_DPAD_CENTER | 23 |
| Back | KEYCODE_BACK | 4 |
| Home | KEYCODE_HOME | 3 |
| Menu | KEYCODE_MENU | 82 |
| Search / Assistant | KEYCODE_SEARCH | 84 |
| Settings | KEYCODE_SETTINGS | 176 |
| Input source | KEYCODE_TV_INPUT | 178 |
| Program guide | KEYCODE_GUIDE | 172 |
| Channel up / down | KEYCODE_CHANNEL_UP / KEYCODE_CHANNEL_DOWN | 166 / 167 |
Several presses in one command are faster than separate commands, because each adb shell call has its own start-up cost:
adb shell input keyevent KEYCODE_DPAD_DOWN KEYCODE_DPAD_DOWN KEYCODE_DPAD_CENTERHolding a button, for example to open a context menu, uses --longpress:
adb shell input keyevent --longpress KEYCODE_DPAD_CENTERVolume and media
| Action | Key name | Code |
|---|---|---|
| Volume up / down | KEYCODE_VOLUME_UP / KEYCODE_VOLUME_DOWN | 24 / 25 |
| Mute | KEYCODE_VOLUME_MUTE | 164 |
| Play / pause | KEYCODE_MEDIA_PLAY_PAUSE | 85 |
| Stop | KEYCODE_MEDIA_STOP | 86 |
| Next / previous | KEYCODE_MEDIA_NEXT / KEYCODE_MEDIA_PREVIOUS | 87 / 88 |
| Rewind / fast forward | KEYCODE_MEDIA_REWIND / KEYCODE_MEDIA_FAST_FORWARD | 89 / 90 |
| Subtitles | KEYCODE_CAPTIONS | 175 |
Whether the TV changes its own speaker volume or the volume of an attached soundbar depends on the model and its HDMI-CEC settings.
Typing text
On-screen TV keyboards are slow with a remote. Focus the text field first, then:
adb shell input text "breaking%sbad"%s is a space. Characters such as &, ( and ' need escaping for the shell, and input text only types plain ASCII. In ADBKit you can type directly with your keyboard instead, including accented letters. More detail is in ADB input keyevent and text tips.
Opening apps
List the apps you installed yourself:
adb shell pm list packages -3Open an app by package name. TV apps register a "Leanback" launcher entry, so ask for that category:
adb shell monkey -p com.google.android.youtube.tv -c android.intent.category.LEANBACK_LAUNCHER 1A few common TV packages:
| App | Package |
|---|---|
| YouTube for TV | com.google.android.youtube.tv |
| Netflix (Android TV) | com.netflix.ninja |
| Google Play Store | com.android.vending |
| Android TV Settings | com.android.tv.settings |
Package names can differ by region and by device, so check with pm list packages when one does not open. On Fire TV, Amazon's own apps use com.amazon.* names.
Close an app completely:
adb shell am force-stop com.netflix.ninjaOpening a YouTube video or a web link
adb shell am start -a android.intent.action.VIEW -d "https://www.youtube.com/watch?v=VIDEO_ID"If YouTube for TV is installed it opens the video. The same VIEW intent works for other links, as long as some app on the TV handles them. Many TVs have no full web browser, so a plain web page may open nothing.
Settings screens
adb shell am start -a android.settings.SETTINGS
adb shell am start -a android.settings.WIFI_SETTINGS
adb shell am start -a android.settings.APPLICATION_DEVELOPMENT_SETTINGSNot every TV supports every screen. An error such as "Activity not started, unable to resolve Intent" means that screen is missing on this model.
Sleep, wake, reboot
| Action | Command |
|---|---|
| Toggle power (like the remote's power button) | adb shell input keyevent KEYCODE_POWER |
| Go to sleep | adb shell input keyevent KEYCODE_SLEEP |
| Wake up | adb shell input keyevent KEYCODE_WAKEUP |
| Is the screen on? | adb shell dumpsys power, then look for mWakefulness |
| Restart | adb reboot |
Use KEYCODE_SLEEP and KEYCODE_WAKEUP in scripts rather than KEYCODE_POWER, because those two do the same thing every time instead of toggling. Some TVs drop the network connection in deep standby, and then ADB cannot wake them.
Device information
adb shell getprop ro.product.model
adb shell getprop ro.build.version.release
adb shell getprop ro.product.cpu.abilist
adb shell wm size
adb shell df -h /dataro.product.cpu.abilist matters when you install apps. Many TVs run a 32-bit system even on a 64-bit chip, which is why some APKs refuse to install. See installing APKs on Android TV and Fire TV.
Screenshots
adb exec-out screencap -p > tv.pngProtected streaming video shows black in screenshots and recordings. That is expected, not an error.
Turning preinstalled apps off (carefully)
You can hide a preinstalled app you never use without uninstalling it:
adb shell pm disable-user --user 0 com.example.unwanted
adb shell pm enable com.example.unwantedThe second line undoes the first. Do not disable launchers, system UI, setup or update services. A TV with its home screen disabled can be hard to recover without a factory reset.
For the same commands on phones, see the general ADB commands cheat sheet.