I am trying to add touch events from a file to the current application (build a new touch event according to the data found in the file ), and I am trying to understand the chain of calls when a "real" touch event is triggered.
From all the searches I conducted, I found that Activity.dispatchTouchEvent(ev) is the first method called when we have a touch event, then its forwarded to ViewGroup.dispatchTouchEvent and then to View.dispatchTouchEvent.
I want to find what is being called before Activity.dispatchTouchEvent(ev) and how the events is transfered from the HW to this method.
dispatchTouchEvent(MotionEvent) - This allows your Activity to intercept all touch events before they are dispatched to the window. • ViewGroup. onInterceptTouchEvent(MotionEvent) - This allows a ViewGroup to watch events as they are dispatched to child Views.
Intercept touch events in a ViewGroup. The onInterceptTouchEvent() method is called whenever a touch event is detected on the surface of a ViewGroup , including on the surface of its children.
The touch event is passed in as a MotionEvent , which contains the x,y coordinates, time, type of event, and other information. The touch event is sent to the Window's superDispatchTouchEvent() .
After the Math. abs() calls, you're essentially testing if their finger is farther down the screen than it is across the screen. Store the initial down coordinates as member variables and set them during ACTION_DOWN . You declared two floats (touchX and touchY) inside the onTouchEvent method.
Maybe what you want is how android input framework works. The following blog about android input framework architecture may helps you.
Android Input Framework Architecture[Part 1] : Introduction to InputReader & InputDispatcher
The input process can simply be put as:
input hardware ------> kernel/driver(input protocol) -----> EventHub(framework/base/libs/ui) getevent------> InputReader ----> inputDispatcher ----> Window manager.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With