I want to generate a touch event via programming on the screen outside of my app. My app currently has a floating window. I am trying to make something like repetitouch I used the Hover library to create a floating window to display some message and buttons. I tried following this answer but the Hover library doesn't provide me with any views to work on [ when I try to use view.dispatchTouchEvent(motionEvent); ] The ClassName.this, getView() and all don't work. Is there any other floating window library which provides views after implementation so that I can generate touches via code. Can I do this task using services? If yes, what should I use?
Asked
Active
Viewed 1,881 times
2 Answers
0
Updated::::: Refer the following link that shows How to stimulate touch event in android
https://stackoverflow.com/a/23902985/9287163
(Hope you find it useful)

krishank Tripathi
- 616
- 1
- 7
- 23
-
I want to 'generate' touch events programmatically not 'detect' touches from user. – Manas Feb 02 '18 at 10:34
-
I don't think you've bothered to check what my question is and what the hyperlinks are for -_- The link you posted is the exact link i mentioned in the question. – Manas Feb 02 '18 at 12:50
0
I found my solution. I used instrumentation.
InstrumentationObj.sendPointerSync(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, x_coordinate, y_coordinate, 0));

Manas
- 31
- 5
-
Can it be also used in command line ? Because I’m not an android developer and trying to use python to accomplish this – Paul Lam Apr 04 '22 at 13:33