public void hideKeyboard() {
   InputMethodManager inputManager =
       (InputMethodManager)
           getActivity()
               .getSystemService(getActivity().getApplicationContext().INPUT_METHOD_SERVICE);
   if (inputManager.isAcceptingText()) {
     inputManager.hideSoftInputFromWindow(
         getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
   }
 }
 /**
  * Returns whether an InputConnection is available. An InputConnection is available when text
  * input is being directed to the GeckoView, and a text field (input, textarea, contentEditable,
  * etc.) is currently focused inside the GeckoView.
  */
 private boolean hasInputConnection() {
   final InputMethodManager imm = getInputMethodManager();
   return imm.isActive(getView()) && imm.isAcceptingText();
 }