下面列出了android.view.inputmethod.InputMethodManager#restartInput ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void showAtBottomPending() {
isPendingOpen = true;
final InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (Utils.shouldOverrideRegularCondition(context, editText)) {
editText.setImeOptions(editText.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
if (inputMethodManager != null) {
inputMethodManager.restartInput(editText);
}
}
if (inputMethodManager != null) {
emojiResultReceiver.setReceiver(this);
inputMethodManager.showSoftInput(editText, InputMethodManager.RESULT_UNCHANGED_SHOWN, emojiResultReceiver);
}
}
public void dismiss() {
popupWindow.dismiss();
variantPopup.dismiss();
recentEmoji.persist();
variantEmoji.persist();
emojiResultReceiver.setReceiver(null);
if (originalImeOptions != -1) {
editText.setImeOptions(originalImeOptions);
final InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
inputMethodManager.restartInput(editText);
}
if (SDK_INT >= O) {
final AutofillManager autofillManager = context.getSystemService(AutofillManager.class);
if (autofillManager != null) {
autofillManager.cancel();
}
}
}
}
public void stopTextComposing() {
InputMethodManager im = (InputMethodManager) getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
// This is an overkill way to inform the InputMethod that the caret
// might have changed position and it should re-evaluate the
// caps mode to use.
im.restartInput(FreeScrollingTextField.this);
if (_inputConnection != null && _inputConnection.isComposingStarted()) {
_inputConnection.resetComposingState();
}
}
public void stopTextComposing() {
InputMethodManager im = (InputMethodManager) getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
// This is an overkill way to inform the InputMethod that the caret
// might have changed position and it should re-evaluate the
// caps mode to use.
im.restartInput(FreeScrollingTextField.this);
if (_inputConnection != null && _inputConnection.isComposingStarted()) {
_inputConnection.resetComposingState();
}
}
/**
* @see View#onConfigurationChanged(Configuration)
*/
@SuppressWarnings("javadoc")
public void onConfigurationChanged(Configuration newConfig) {
TraceEvent.begin();
if (newConfig.keyboard != Configuration.KEYBOARD_NOKEYS) {
mImeAdapter.attach(nativeGetNativeImeAdapter(mNativeContentViewCore),
ImeAdapter.getTextInputTypeNone(),
AdapterInputConnection.INVALID_SELECTION,
AdapterInputConnection.INVALID_SELECTION);
InputMethodManager manager = (InputMethodManager)
getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
manager.restartInput(mContainerView);
}
mContainerViewInternals.super_onConfigurationChanged(newConfig);
// Make sure the size is up to date in JavaScript's window.onorientationchanged.
mContainerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
mContainerView.removeOnLayoutChangeListener(this);
sendOrientationChangeEvent();
}
});
// To request layout has side effect, but it seems OK as it only happen in
// onConfigurationChange and layout has to be changed in most case.
mContainerView.requestLayout();
TraceEvent.end();
}
/**
* @see View#onConfigurationChanged(Configuration)
*/
@SuppressWarnings("javadoc")
public void onConfigurationChanged(Configuration newConfig) {
TraceEvent.begin();
if (newConfig.keyboard != Configuration.KEYBOARD_NOKEYS) {
mImeAdapter.attach(nativeGetNativeImeAdapter(mNativeContentViewCore),
ImeAdapter.getTextInputTypeNone(),
AdapterInputConnection.INVALID_SELECTION,
AdapterInputConnection.INVALID_SELECTION);
InputMethodManager manager = (InputMethodManager)
getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
manager.restartInput(mContainerView);
}
mContainerViewInternals.super_onConfigurationChanged(newConfig);
// Make sure the size is up to date in JavaScript's window.onorientationchanged.
mContainerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
mContainerView.removeOnLayoutChangeListener(this);
sendOrientationChangeEvent();
}
});
// To request layout has side effect, but it seems OK as it only happen in
// onConfigurationChange and layout has to be changed in most case.
mContainerView.requestLayout();
TraceEvent.end();
}
private void restartInput() {
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.restartInput(this);
}
}