0
在Android源代碼中,Android在從硬件接收到按鍵被按下的通知時調用onKeyDown()
?在Android源代碼中,KeyEvent調度程序發送到onKeyDown的位置?
在Android源代碼中,Android在從硬件接收到按鍵被按下的通知時調用onKeyDown()
?在Android源代碼中,KeyEvent調度程序發送到onKeyDown的位置?
/**
* Deliver this key event to a {@link Callback} interface. If this is
* an ACTION_MULTIPLE event and it is not handled, then an attempt will
* be made to deliver a single normal event.
*
* @param receiver The Callback that will be given the event.
* @param state State information retained across events.
* @param target The target of the dispatch, for use in tracking.
*
* @return The return value from the Callback method that was called.
*/
public final boolean dispatch(Callback receiver, DispatcherState state,
Object target) {
switch (mAction) {
case ACTION_DOWN: {
mFlags &= ~FLAG_START_TRACKING;
if (DEBUG) Log.v(TAG, "Key down to " + target + " in " + state
+ ": " + this);
boolean res = receiver.onKeyDown(mKeyCode, this);
if (state != null) {
if (res && mRepeatCount == 0 && (mFlags&FLAG_START_TRACKING) != 0) {
if (DEBUG) Log.v(TAG, " Start tracking!");
state.startTracking(this, target);
} else if (isLongPress() && state.isTracking(this)) {
try {
if (receiver.onKeyLongPress(mKeyCode, this)) {
if (DEBUG) Log.v(TAG, " Clear from long press!");
state.performedLongPress(this);
res = true;
}
} catch (AbstractMethodError e) {
}
}
}
return res;
}
我試圖儘可能的低,因爲我們可以走了。在KeyEvent接收到一個按鍵被按下的中斷後,固件'dispatch()'在哪裏? – styler1972
好的,我還沒有完全想到這一點,但在某處isSystem()被調用,並且(理論上)根據這個布爾結果將KeyEvent發送給應用程序。感謝你的回答 – styler1972