I developed a special soft keyboard based on the sample Android soft keyboard.
The problem that I encountered is restarting the device and clicking on EditText in the Android environment, my keyboard is not displayed, and I need to go to the Android login settings, change the default keyboard and select my keyboard again. After that, when I click on EditText, my keyboard is displayed and everything is fine until the next device reboots.
What could be the source of this error?
manifest:
<application android:label="@string/ime_name" >
<service
android:name="com.test.softkeyboard.SoftKeyboard"
android:permission="android.permission.BIND_INPUT_METHOD" >
<intent-filter >
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data
android:name="android.view.im"
android:resource="@xml/method" />
</service>
</application>
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
Some of my methods are:
@Override
public void onCreate() {
super.onCreate();
mWordSeparators = getResources().getString(R.string.word_separators);
}
@Override
public View onCreateCandidatesView() {
mCandidateView = new CandidateView(this);
mCandidateView.setService(this);
return mCandidateView;
}
@Override
public View onCreateInputView() {
mInputView = (KeyboardView) getLayoutInflater().inflate(
R.layout.input, null);
mInputView.setOnKeyboardActionListener(this);
mInputView.setKeyboard(loadState());
return mInputView;
}
@Override
public void onDisplayCompletions(CompletionInfo[] completions) {
if (mCompletionOn) {
mCompletions = completions;
if (completions == null) {
setSuggestions(null, false, false);
return;
}
List<String> stringList = new ArrayList<String>();
for (int i = 0; i < (completions != null ? completions.length : 0); i++) {
CompletionInfo ci = completions[i];
if (ci != null)
stringList.add(ci.getText().toString());
}
setSuggestions(stringList, true, true);
}
}
@Override
public void onFinishInput() {
super.onFinishInput();
mComposing.setLength(0);
updateCandidates();
setCandidatesViewShown(false);
saveState(mCurKeyboard);
if (mInputView != null) {
mInputView.closing();
}
}
@Override
public void onInitializeInterface() {
if (mQwertyKeyboard_Fa != null) {
int displayWidth = getMaxWidth();
if (displayWidth == mLastDisplayWidth)
return;
mLastDisplayWidth = displayWidth;
}
mQwertyKeyboard_Fa = new LatinKeyboard(this, R.xml.qwerty_fa);
mQwertyKeyboard_En = new LatinKeyboard(this, R.xml.qwerty_en);
mSymbolsKeyboard = new LatinKeyboard(this, R.xml.symbols);
mSymbolsShiftedKeyboard = new LatinKeyboard(this, R.xml.symbols_shift);
mSymbolsSimpleKeyboard = new LatinKeyboard(this, R.xml.symbols_simple);
}
@Override
public void onStartInputView(EditorInfo attribute, boolean restarting) {
super.onStartInputView(attribute, restarting);
mInputView.setKeyboard(mCurKeyboard);
mInputView.closing();
}