public class VirturlKeyPadCtr {
private static Instrumentation mInstrumentation;
public static void RC_ConttrollerAction(final int keyValue) {
/**
* Wrapper-function taking a KeyCode. A complete KeyStroke is DOWN and UP
* Action on a key!
*/
public static void simulateKeystroke(int KeyCode) {
if (mInstrumentation == null) {
mInstrumentation = new Instrumentation();
}
mInstrumentation.sendKeyDownUpSync(KeyCode);
}
}
寫一個類工具類到時候方便調用
調用的時候直接
VirturlKeyPadCtr.simulateKeystroke(realCode);
傳人的參數為你的遙控器的KEY值,比如返回鍵就是KeyEvent.KEYCODE_BACK