I want to simulate a touch event. I am using this code
MotionEvent.PointerCoords[] coords = { new MotionEvent.PointerCoords() }; coords[0].x = 200; coords[0].y = 200; int[] ptrs = { 0 }; MotionEvent event =MotionEvent.obtain(SystemClock.uptimeMillis(),SystemClock.uptimeMillis(), action, 1, ptrs, coords, 0, 1, 1, 0, 0, InputDevice.SOURCE_TOUCHPAD, 0); windowManager.injectPointerEvent(event, false);
problem with this line
windowManager.injectPointerEvent(event, false);
that I cannot access WindowManger. When I try to use this
WindowManager windowmanager=(WindowManager) Context.getSystemService(Context.WINDOW_SERVICE);
I received an error message. "It is not possible to make a static reference to the non-static method getSystemService (String) of type Context"
Can someone help me !!
Ahmed source share