18

Is there a way to get the use ADB to simulate a Recent App key press? I do not see it in the list of assigned keys and I am not able to select it using adb input shell tap despite getting the coordinates from the debugging options.

I am trying to automate a task on my own personal phone (Nexus 5 with soft keys) so any hacky way is fine, assuming there is not a clean way to do this.

Community
  • 1
  • 1
UserIsStuck
  • 519
  • 1
  • 6
  • 18

3 Answers3

30

The solution is to use the KEYCODE_APP_SWITCH KeyEvent:

adb shell input keyevent KEYCODE_APP_SWITCH
Simon Marquis
  • 7,248
  • 1
  • 28
  • 43
16

See @SimonMarquis answer below

adb shell input keyevent KEYCODE_APP_SWITCH

(OBSOLETE)

I don't think there is a keycode for it.

However, I am able to open the recent apps menu with adb shell input tap (testing on a Nexus 5 with Lollipop). For example:

adb shell input tap 800 1890
matiash
  • 54,791
  • 16
  • 125
  • 154
  • That did it. I was working in Landscape for my other coordinates - I had my x's and y's mixed up when I got back to the home screen. – UserIsStuck Nov 08 '14 at 22:45
  • Too specific to physical devices and even OSs. @SimpnMarquis' solution is universal. – Ky - Feb 05 '16 at 15:51
  • 1
    @BenC.R.Leggiero Agreed, didn't know about it at the time. Cannot delete the answer while it's accepted though :/ – matiash Feb 05 '16 at 16:15
  • 1
    Maybe @UserIsStuck can accept the other? Until then I think your edit will do :) – Ky - Feb 05 '16 at 16:47
0
adb shell input keyevent KEYCODE_APP_SWITCH

Still works, you don't even have to put its numeric value (187) into the command.