monkeyrunner - get currently active application?

1.3k Views Asked by At

I'm using the android monkeyrunner to automatically run my application.

monkeyDevice.executeShellCommand("am start -a android.intent.action.MAIN -n " 
            + name + " -e test_id " + test_id, new NullOutputReceiver());

Is it possible to get the name of the active application that is on the emulator screen using monkeyrunner?

1

There are 1 best solutions below

2
On BEST ANSWER

You can get the current focused window using:

hv = monkeyDevice.getHierarchyViewer()
windowName = hv.getFocusedWindowName()