/**
* 模拟硬键盘发送
*/
private void sendToApp() {
String currentPkgName = mImeService.getImeService().getCurrentInputEditorInfo().packageName;
if (mContext.getString(R.string.setting_tencent_mm_package).equals(currentPkgName)) {
InputConnection inputconnection = mImeService.getInputConnection();
CharSequence cb = inputconnection.getTextAfterCursor(1000, 0);
CharSequence ca = inputconnection.getTextBeforeCursor(1000, 0);
int len = cb.length() + ca.length();
inputconnection.setSelection(len, len);
mImeService.sendKeyEvent(KeyEvent.KEYCODE_DPAD_RIGHT);
mImeService.sendKeyEvent(KeyEvent.KEYCODE_DPAD_RIGHT);
try {
TimeUnit.MILLISECONDS.sleep(50);
} catch (InterruptedException e) {
// just ignore
}
mImeService.sendKeyEvent(KeyEvent.KEYCODE_DPAD_CENTER);
// try {
// TimeUnit.MILLISECONDS.sleep(50);
// } catch (InterruptedException e) {
// // just ignore
// }
// mImeService.sendKeyEvent(KeyEvent.KEYCODE_DPAD_LEFT);
// mImeService.sendKeyEvent(KeyEvent.KEYCODE_DPAD_LEFT);
} else {
mImeService.setHcrFullCheckMode();
showEditPopWindow();
}
}
android 模拟按键
最新推荐文章于 2022-09-09 19:11:35 发布