Android - 使用硬件后退按钮解除键盘关闭时获取回调

时间:2017-05-01 15:41:41

标签: android keyboard back dismiss

我正在以这种方式启动键盘:

    InputMethodManager inputMethodService = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodService != null && inputMethodService.isActive()) {
        inputMethodService.showSoftInput(view, 0);
    }

我正在以这种方式捕捉“完成”:

   editField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE) {
                ...
                return true;
            }
            return false;
        }
    });

单击硬件后退按钮时,上述方法不会触发。我该如何捕获它?

编辑:我们已尝试onBackPressed()onResume()onKeyDown()onActivityResult()

0 个答案:

没有答案