我得到了
D/InputEventConsistencyVerifier( 2144): KeyEvent: ACTION_UP but key was not down.`
D/InputEventConsistencyVerifier( 2144): in com.android.internal.policy.impl.PhoneWindow$DecorView@41689658
当我尝试在我的活动中执行此操作时,警告全部:
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if ((/*some boolean checks*/) && (event.getAction() == KeyEvent.ACTION_DOWN)) {
/*some custom functions*/
return true;
}
}
return super.dispatchKeyEvent(event);
}
在活动级别覆盖dispatchKeyEvent
的正确方法是什么?这些警告好吗?我应该在onKeyUp
和onKeyDown
我的观点中进行相应的更改吗?
答案 0 :(得分:6)
试试这个
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
if (event.getAction() == KeyEvent.ACTION_UP){
enter();
return true;
}}
return super.dispatchKeyEvent(event);
};