参考:https://www.cnblogs.com/TerryBlog/archive/2012/06/07/2539866.html
一,Andmenifest.xml中添加system权限
android:sharedUserId="android.uid.system"
二,sendKeyDownUpSync发送keyevent
public void sendFrameworkKeyEvent(int keyEvent) {
final int keyCode = keyEvent;
new Thread(new Runnable() {
public void run() {
try {
SkyALinkLog.d(TAG, "SendFrameworkKeyEvent begin = " + keyCode);
new Instrumentation().sendKeyDownUpSync(keyCode);
SkyALinkLog.d(TAG, "SendFrameworkKeyEvent end = " + keyCode);
} catch (Exception exception) {
SkyALinkLog.d(TAG, "SendFrameworkKeyEvent = " + exception.toString());
}
}
}).start();
}