Reputation: 722
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 transferred from the HW to this method.
Upvotes: 8
Views: 2869
Reputation: 31
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.
Upvotes: 3
Reputation: 21
In Activty the method dispatchTouchEvent is :
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
onUserInteraction();
}
if (getWindow().superDispatchTouchEvent(ev)) {
return true;
}
return onTouchEvent(ev);
}
you must call super.dispatchTouchEvent()
method in ur own activity.
so that u can reach this line :getWindow().superDispatchTouchEvent(ev)
getWindwow()
return the instance of PhoneWindow.
PhoneWindow.superDispatchTouchEvent()
will call the DecorView's method
,and in that method ,DecorView.dispatchTouchEvent
will be called.
So the event has been passed to the views.
//in Class PhoneWindow
public boolean superDispatchTouchEvent(MotionEvent event) {
return mDecor.superDispatchTouchEvent(event);
}
and
//in class DecorView
public boolean superDispatchTouchEvent(MotionEvent event) {
return super.dispatchTouchEvent(event);
}
Upvotes: 2