What is the difference between onKey(), OnKeyDown() and dispatchKeyEvent() methods provided by Android?
I Would like to know when and where each of these can be used.
Please shed some light into this.
Tracing the source code of the 5.1 Source for the View Class. It would seem that
dispatchKeyEvent() is the first method called by the system. Overloading it will prevent any and all key events from being called unless the base version is called.
dispatchKeyEvent()'s first move is to attempt to pass the event to an
onKeyListener if there is one. This is when
onKey() is called. If the
onKey() implementation returns
dispatchKeyEvent() will return there and other events will not be called.
If there is no
onKeyListener or the
onKey() method returned
dispatchKeyEvent() will then call the
dispatch() method. Which will then in turn call all the methods in the
KeyEvent.Callback interface on your view. This includes