Wednesday, August 03, 2011

Android Monkey Script DispatchPress Bug

When using Monkey Script I noticed that DispatchPress(KEYCODE_BACK)
is doing nothing which really suck. In many cases this is due to the fact that the Activity doesn't consume the Key event.
The solution to this problem is to use a mix of monkey script and
adb shell input command in a sequence.

1 Using monkey script gave some great timing
control. Wait a certain amount of second for the activity and is a
blocking adb call.
2 Finally sending adb shell input keyevent 4 will end the running APK.

EG

adb shell monkey -p com.my.application -v -v -v -f /sdcard/monkey_script.txt 1
adb shell input keyevent 4

No comments: