Код: Выделить всё
java.lang.NoSuchMethodException: com.example.receiver.InputManager.getInstance []
at java.lang.Class.getMethod(Class.java:2937)
at java.lang.Class.getDeclaredMethod(Class.java:2914)
at com.example.receiver.InputHandler.getInputManager(InputHandler.java:59)
at com.example.receiver.InputHandler.injectInputEvent(InputHandler.java:43)
at com.example.receiver.InputHandler.Handle(InputHandler.java:84)
at com.example.receiver.Main.main(Main.java:38)
at com.example.receiver.MainActivity.lambda$onCreate$0(MainActivity.java:21)
at com.example.receiver.MainActivity$$ExternalSyntheticLambda0.run(Unknown Source:2)
Код: Выделить всё
private void injectInputEvent(MotionEvent event) {
try {
getInjectInputEvent().invoke(getInputManager(), event, 0);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
}
}
private static Method getInjectInputEvent() throws NoSuchMethodException {
Class cl = InputManager.class;
Method method = cl.getDeclaredMethod("injectInputEvent", InputEvent.class, int.class);
method.setAccessible(true);
return method;
}
private static InputManager getInputManager() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Class cl = InputManager.class;
Method method = cl.getDeclaredMethod("getInstance");
method.setAccessible(true);
return (InputManager) method.invoke(cl);
}
Код: Выделить всё
Код: Выделить всё
am start com.example.receiver/com.example.receiver.MainActivity
почему это не работает для моего?
У меня нет root-доступ.
Я ожидал, что приложение сможет использовать InjectInputEvents, но оно не смогло этого сделать.
Я пробовал запустить его из оболочки adb и из студии Android, которая не имело никакого значения.
Подробнее здесь: https://stackoverflow.com/questions/782 ... t-instance
Мобильная версия