Reputation: 1933
I have a very simple InputMethodService where all I do is log the different stages of the lifecycle. My onCreateInputView
is never called, and the log shows strange things.
MyInput D onCreate
D onInitializeInterface
D onBindInput
D onStartInput
D onUnbindInput
D onBindInput
D onStartInput
D onUnbindInput
D onBindInput
D onStartInput
D onShowInputRequested
I only clicked on a text input when the onShowInputRequested
is called. When a navigate between screens, it cycles between onBind
, onStartInput
, onUnbind
. Am I missing something?
public class MyInput extends InputMethodService {
private static final String TAG = "MyInput";
private InputMethodManager mInputMethodManager;
@Override
public void onCreate() {
super.onCreate();
mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
Log.d(TAG, "onCreate");
}
@Override
public void onInitializeInterface() {
super.onInitializeInterface();
Log.d(TAG, "onInitializeInterface");
}
@Override
public View onCreateInputView() {
Log.d(TAG, "onCreateInputView");
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
return inflater.inflate(R.layout.my_keyboard, null);
}
@Override
public void onFinishInput() {
super.onFinishInput();
Log.d(TAG, "onFinishInput");
}
@Override
public void onStartInput(EditorInfo attribute, boolean restarting) {
super.onStartInput(attribute, restarting);
Log.d(TAG, "onStartInput");
}
@Override
public void onFinishInputView(boolean finishingInput) {
super.onFinishInputView(finishingInput);
Log.d(TAG, "onFinishInputView");
}
@Override
public boolean onShowInputRequested(int flags, boolean configChange) {
Log.d(TAG, "onShowInputRequested");
return super.onShowInputRequested(flags, configChange);
}
@Override
public void onBindInput() {
super.onBindInput();
Log.d(TAG, "onBindInput");
}
@Override
public void onUnbindInput() {
super.onUnbindInput();
Log.d(TAG, "onUnbindInput");
}
@Override
public void onStartInputView(EditorInfo attribute, boolean restarting) {
super.onStartInputView(attribute, restarting);
Log.d(TAG, "onStartInputView restarting = " + restarting);
}
@Override
public void onCurrentInputMethodSubtypeChanged(InputMethodSubtype subtype) {
Log.d(TAG, "onCurrentInputMethodSubtypeChanged");
}
}
Upvotes: 2
Views: 3380
Reputation: 1894
Try to change onShowInputRequested:
@Override
public boolean onShowInputRequested(int flags, boolean configChange) {
return true;
}
I had generally the same, that in some cases my keyboard was not showing, and this helped me.
Upvotes: 2
Reputation: 1933
I've removed all the overriden method and left only the onCreateInputView
and it is now called, no idea what wasn't working, especially because I was calling the superclass methods everywhere...
Upvotes: 1