我有一个非常简单的 InputMethodService,我所做的就是记录生命周期的不同阶段。我onCreateInputView
的从未被调用,日志显示奇怪的事情。
MyInput D onCreate
D onInitializeInterface
D onBindInput
D onStartInput
D onUnbindInput
D onBindInput
D onStartInput
D onUnbindInput
D onBindInput
D onStartInput
D onShowInputRequested
onShowInputRequested
我只在调用时单击了文本输入。当在屏幕之间导航时,它会在onBind
、onStartInput
、之间循环onUnbind
。我错过了什么吗?
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");
}
}