Example usage for android.view.inputmethod InputMethodManager toggleSoftInput

List of usage examples for android.view.inputmethod InputMethodManager toggleSoftInput

Introduction

In this page you can find the example usage for android.view.inputmethod InputMethodManager toggleSoftInput.

Prototype

public void toggleSoftInput(int showFlags, int hideFlags) 

Source Link

Document

This method toggles the input method window display.

Usage

From source file:Main.java

public static void showKeyboard(Activity activity, View view) {
    if (activity != null) {
        if (view != null) {
            view.requestFocus();/* ww  w  .  j  av  a  2 s .  com*/
        }
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
            imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
        }
    }
}

From source file:io.trigger.forge.android.modules.keyboard.API.java

public static void show() {
    InputMethodManager mgr = getKeyboard();
    mgr.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}

From source file:Main.java

public static void showSoftInput(Context context) {
    InputMethodManager inputMethodManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:io.trigger.forge.android.modules.keyboard.API.java

public static void hide() {
    InputMethodManager mgr = getKeyboard();
    mgr.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
    //ForgeApp.getActivity().getWindow().setSoftInputMode(
    //         WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}

From source file:Main.java

public static void showKeyboard(EditText view) {
    InputMethodManager imm = (InputMethodManager) view.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    view.requestFocus();//from  w  ww. j a  va2  s. c  o m
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}

From source file:Main.java

public static void showSoftKeyBoard(Context context, EditText edit) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(edit, InputMethodManager.RESULT_SHOWN);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}

From source file:Main.java

/**
 * Force show soft keyboard with show flag = InputMethodManager.SHOW_FORCED and hide flag = 0.
 * @param context Context to get system service input method.
 * @param viewBinder View has current focus.
 *///from   w w w. j ava 2  s.c om
public static void forceShowSoftInput(Context context, View view) {
    if (view != null) {
        view.requestFocus();
    }
    InputMethodManager inputManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); //Hide Flag = 0
}

From source file:Main.java

public static void toggleKeyboard(Activity activity) {
    InputMethodManager inputMethodManager = (InputMethodManager) activity
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager.isActive()) {
        inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
    }//from   ww w  .java  2 s .  co  m
}

From source file:Main.java

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);
    }/*from   ww w  .ja v  a 2 s  .co  m*/
}

From source file:Main.java

public static void hideSoftKeyboard(Context context) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    // imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
    if (imm.isActive()) {
        imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS);
    }/*from   www  . j av a2s .c om*/
}