2

I am using the

adb shell input keyevent KEYCODE_DPAD_LEFT

to focus on an application, now i want to know the name of the application on which this has focussed using adb shell command.

NOTE: not exactly the name of application, it can focus on anything. SO i want to get the Text on which it focusses.

user1747819
  • 301
  • 1
  • 5
  • 11

2 Answers2

1

Ok. To do it, you need to use grep terminal application on your phone (the easiest way with rooted phone with busybox package). Let do the same steps as below:

C:\Users\Hasan>adb shell input keyevent KEYCODE_DPAD_LEFT

C:\Users\Hasan>adb shell
shell@android:/ $ su
su
root@android:/ # dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'
dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'
  mCurrentFocus=Window{42079c60 com.jrummy.liberty.toolboxpro/com.jrummy.apps.rom.toolbox.RomToolboxActivity paused=false}
  mFocusedApp=AppWindowToken{4283d918 token=Token{426709a8 ActivityRecord{41e37c60 com.jrummy.liberty.toolboxpro/com.jrummy.apps.rom.toolbox.RomToolboxActivity}}}
root@android:/ #

Now you'll see which activity has focus :)

Michał Rowicki
  • 1,372
  • 1
  • 16
  • 28
1

You can use:

adb shell uiautomator dump /dev/tty

You will get an XML describing the current screen, one of the many <node>-elements will have an attribute focused="true". It may also have a text-attribute and a lot more UI-informations.

Sascha N.
  • 65
  • 1
  • 6