Keyevent to click on Alert Dialog of Android screen

adb, android, android-alertdialog, key-events, monkeyrunner

Solution

One indirect way is:-

adb shell uiautomator dump /data/view.xml
adb shell cat /data/view.xml

calculate OK button coordinates from the relative coordinates given in the xml file. Then do

adb shell input tap <x> <y>

Hope works.

Problem

Is there any way to simulate keyevent on "OK" or "CANCEL" buttons of Android dialogue box using adb commands?

Original source