http://davanum.wordpress.com/2007/12/19/android-simulate-key-strokes/KeyEvent ke_c = new KeyEvent(KeyEvent.FLAG_LONG_PRESS, KeyEvent.KEYCODE_POWER); 第一个参数传Action不是flag
public KeyEvent (int action, int code) Create a new key event. Parametersaction action Action code: either ACTION_DOWN, ACTION_UP, or ACTION_MULTIPLE. code The key code.
我尝试过分别两次发送DOWN和up的event,还是没有效果。 downEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_POWER); upEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_POWER);
第一个参数传Action不是flag
Parametersaction
action Action code: either ACTION_DOWN, ACTION_UP, or ACTION_MULTIPLE.
code The key code.
downEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_POWER);
upEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_POWER);