//KeyEvent.KEYCODE_MENU
//KeyEvent.KEYCODE_BACK
public static void sendKeyEvent(final int KeyCode) {
new Thread() { //不可在主线程中调用
public void run() {
try {
Instrumentation inst = new Instrumentation();
inst.sendKeyDownUpSync(KeyCode);
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();
}android-代码里模拟发送按键,布布扣,bubuko.com
原文:http://blog.csdn.net/centralperk/article/details/22925293