Issue
I know this is a bit repeating question. I have reviewed various questions on SO and few other sites but could not find a single answer that satisfies my need.
Requirement
1) I have X,Y coordinates, I want to create MotionEvent and dispatch it to topmost activity/view.
2) I have to inject it in my own App. So Inject_Events permission should not be required.
3) While I have the coordinates, I do not know, Activity or View which are at that position. So Activity.dispatchTouchEvent does not work for me.. (view.dispatchTouchEvent will work but I do not know the view).
4) Instrumentation does not help either because they do not have single method to inject touch event at x,y location.
5) InputManager has hidden method injectInputEvent but I don't know how to access injectInputEvent and compile it?
Any help appreciated!
Solution
For the benefit of larger group - rootViewController.dispatchTouchEvent
(instead of activity.rootViewController
) works like a charm.
Answered By - TorukMakto
Answer Checked By - Terry (JavaFixing Volunteer)