Android: การส่ง key (simulate key press)

You can use instrumentation, ie following code called from onCreate of your activity will cause menu to be opened and closed multiple times:

MainActivity.java

บรรทัดที่ 20 : เรียกใช้ Instrumentation

พอรันแล้วเหมือนถูกกด Back แล้วแอพก็หายไปเลย ไม่กลับมา
แต่ก็ถือว่าส่งคีย์ได้

 

Link