@Override
 public void onSaveInputMethodPreference(final InputMethodPreference pref) {
   final boolean hasHardwareKeyboard =
       getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY;
   InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(
       this, getContentResolver(), mImm.getInputMethodList(), hasHardwareKeyboard);
   // Update input method settings and preference list.
   mInputMethodSettingValues.refreshAllInputMethodAndSubtypes();
   for (final InputMethodPreference p : mInputMethodPreferenceList) {
     p.updatePreferenceViews();
   }
 }
  @Override
  public void onPause() {
    super.onPause();

    mIm.unregisterInputDeviceListener(this);
    mSettingsObserver.pause();

    if (SHOW_INPUT_METHOD_SWITCHER_SETTINGS) {
      mShowInputMethodSelectorPref.setOnPreferenceChangeListener(null);
    }
    InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(
        this, getContentResolver(), mImis, !mHardKeyboardPreferenceList.isEmpty());
  }