public void restoreState(IMControlPanel controlPanel) { // restore state of control panel itself StateBundle cpState = new StateBundle(mPreferences, PREFIX + ".", false); int methodId = cpState.getInt("activeMethodIndex", 0); if (methodId != -1) { controlPanel.activateInputMethod(methodId); } // restore state of all input methods for (InputMethod im : controlPanel.getInputMethods()) { StateBundle savedState = new StateBundle(mPreferences, PREFIX + "." + im.getInputMethodName(), false); im.onRestoreState(savedState); } }