Java Code Examples for android.view.inputmethod.InputMethodManager#showSoftInputFromInputMethod()

The following examples show how to use android.view.inputmethod.InputMethodManager#showSoftInputFromInputMethod() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SearchBarLayout.java    From Alibaba-Android-Certification with MIT License 5 votes vote down vote up
public void hiddenKeybord() {
	InputMethodManager manager = ((InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE));
	if(manager==null){
		return;
	}
	boolean isOpen = manager.isActive(); // 判断软键盘是否打开
	if (isOpen && manager != null) {
		manager.hideSoftInputFromWindow(mEditText.getWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS);
	}else{
		manager.showSoftInputFromInputMethod(mEditText.getWindowToken(), 0);
	}
}
 
Example 2
Source File: CommonUtils.java    From firebase-android-sdk with Apache License 2.0 5 votes vote down vote up
public static void openKeyboard(Context context, View view) {
  final InputMethodManager imm =
      (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
  if (imm != null) {
    imm.showSoftInputFromInputMethod(view.getWindowToken(), 0);
  }
}
 
Example 3
Source File: CommonUtils.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 显示软键盘
 * @param activity
 */
public static void showKeyboard(Activity activity) {
    if (activity != null) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (!imm.isActive()) {
            imm.showSoftInputFromInputMethod(activity.getCurrentFocus().getWindowToken(), 0);
        }
    }
}
 
Example 4
Source File: ScreenUtils.java    From PlayTogether with Apache License 2.0 5 votes vote down vote up
/**
 * 显示软键盘
 */
public static void showKeyboard(Context context)
{
	Activity activity = (Activity) context;
	if (activity != null)
	{
		InputMethodManager imm = (InputMethodManager) activity
						.getSystemService(Context.INPUT_METHOD_SERVICE);
		imm.showSoftInputFromInputMethod(activity.getCurrentFocus()
						.getWindowToken(), 0);
		imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
	}
}
 
Example 5
Source File: AEditText.java    From Stylish-Widget-for-Android with Apache License 2.0 5 votes vote down vote up
public void showKeyboard(View view) {
    if (view != null) {
        InputMethodManager imm = (InputMethodManager) getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null)
            imm.showSoftInputFromInputMethod(view.getWindowToken(), 0);
    }
}
 
Example 6
Source File: CommonUtils.java    From sealtalk-android with MIT License 5 votes vote down vote up
/**
 * 显示软键盘
 * @param activity
 */
public static void showKeyboard(Activity activity) {
	if(activity != null){
		InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
		if(!imm.isActive()){
			imm.showSoftInputFromInputMethod(activity.getCurrentFocus().getWindowToken(), 0);
		}
	}
}
 
Example 7
Source File: NotificationReceiver.java    From hackerskeyboard with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    Log.i(TAG, "NotificationReceiver.onReceive called, action=" + action);

    if (action.equals(ACTION_SHOW)) {
        InputMethodManager imm = (InputMethodManager)
            context.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
            imm.showSoftInputFromInputMethod(mIME.mToken, InputMethodManager.SHOW_FORCED);
        }
    } else if (action.equals(ACTION_SETTINGS)) {
        context.startActivity(new Intent(mIME, LatinIMESettings.class));
    }
}
 
Example 8
Source File: KJChatKeyboard.java    From EmojiChat with Apache License 2.0 5 votes vote down vote up
/**
 * 显示软键盘
 */
public static void showKeyboard(Context context) {
    Activity activity = (Activity) context;
    if (activity != null) {
        InputMethodManager imm = (InputMethodManager) activity
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInputFromInputMethod(activity.getCurrentFocus()
                .getWindowToken(), 0);
        imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
    }
}
 
Example 9
Source File: SoftInput.java    From Utils with Apache License 2.0 5 votes vote down vote up
/**
 * Show the input method's soft input area, so the user sees the input method window and can interact with it.
 * This can only be called from the currently active input method, as validated by the given token.
 *
 * @param view the current focused view
 */
public static void showSoftInputFromInputMethod(View view) {
    if (view != null) {
        Context context = view.getContext();
        IBinder windowToken = view.getWindowToken();
        InputMethodManager inputMethodManager = (InputMethodManager) context
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.showSoftInputFromInputMethod(windowToken, 0);
    }
}
 
Example 10
Source File: MessageInputToolBox.java    From Android-Chat-Widget with Apache License 2.0 5 votes vote down vote up
/**
 * 显示软键盘
 * @param activity
 */
public static void showKeyboard(Context context) {
	Activity activity = (Activity) context;
	if(activity != null){
		InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
		imm.showSoftInputFromInputMethod(activity.getCurrentFocus().getWindowToken(), 0);
		imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
	}
}
 
Example 11
Source File: RSoftInputLayout.java    From imsdk-android with MIT License 4 votes vote down vote up
public void showSoftInput() {
    InputMethodManager manager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    manager.showSoftInputFromInputMethod(getWindowToken(), 0);
}
 
Example 12
Source File: AppUtil.java    From ucar-weex-core with Apache License 2.0 4 votes vote down vote up
/**
 * 显示软键盘(根据焦点所在的控件)
 */
public static void showSoftInput(Context c, View foucsView) {
    InputMethodManager imm = (InputMethodManager) c.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInputFromInputMethod(foucsView.getWindowToken(), 0);
}
 
Example 13
Source File: CommonUtils.java    From letv with Apache License 2.0 4 votes vote down vote up
public static void openKeyboard(Context context, View view) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService("input_method");
    if (imm != null) {
        imm.showSoftInputFromInputMethod(view.getWindowToken(), 0);
    }
}