import android.hardware.input.InputManager;
private long mKeyRemappingSendFakeKeyDownTime;
private void keyRemappingSendFakeKeyEvent(int action, int keyCode) {
long eventTime = SystemClock.uptimeMillis();
if (action == KeyEvent.ACTION_DOWN) {
mKeyRemappingSendFakeKeyDownTime = eventTime;
}
KeyEvent keyEvent = new KeyEvent(mKeyRemappingSendFakeKeyDownTime, eventTime, action, keyCode, 0);
InputManager inputManager = (InputManager) mContext.getSystemService(Context.INPUT_SERVICE);
inputManager.injectInputEvent(keyEvent, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
}
android模拟发送键值
最新推荐文章于 2024-08-18 03:39:28 发布