0

使用log.d和函数作为:

@Override
public void onBackPressed(){
    Log.d("back","back");
    }
}

看来,最小化键盘的按钮未被识别为后退按钮。是否有一种解决方法可以找到此按钮的 keyID,或者它是否确实存在并且我做错了什么?

使用设备:Xperia Z1 C6902

4

1 回答 1

1

Use this method

protected boolean onKeyDown(int keyCode, KeyEvent event) {
     if (keyCode == KeyEvent.KEYCODE_BACK) {
        // do whatever you want to do
        return true;
     }
     return false;
 }

Refer Back and other keys. But if onBackPressed is not working, also try to implement onKeyDown method where you handle keycode for back.

于 2014-06-22T17:39:09.773 回答