Example usage for android.view.inputmethod InputMethodManager showSoftInput

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

Introduction

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

Prototype

public boolean showSoftInput(View view, int flags) 

Source Link

Document

Synonym for #showSoftInput(View,int,ResultReceiver) without a result receiver: explicitly request that the current input method's soft input area be shown to the user, if needed.

Usage

From source file:Main.java

public static void setKeyboardVisible(Context context, View view, boolean visible) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Service.INPUT_METHOD_SERVICE);
    if (imm == null) {
        return;//from   w ww  . java  2  s .com
    }

    if (visible) {
        imm.showSoftInput(view, 0);
    } else {
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }
}

From source file:Main.java

/**
 * Request to hide the soft input window from the context of the window that
 * is currently accepting input./*from  w  ww. j  a  va 2  s. c  om*/
 * 
 * @param activity
 *            The currently activity, which shows the view receives soft
 *            keyboard input
 */
public static void showKeyboard(Activity activity) {
    if (null == activity) {
        return;
    }
    InputMethodManager im = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    View v = activity.getCurrentFocus();
    if (v != null) {
        im.showSoftInput(v, InputMethodManager.RESULT_UNCHANGED_SHOWN);
    }
}

From source file:Main.java

public static void softKeyboardDelayed(final View view) {
    view.post(new Runnable() {
        @Override/* w ww .  ja  v  a2  s . c om*/
        public void run() {
            if (!isHardwareKeyboardAvailable(view.getContext())) {
                InputMethodManager imm = (InputMethodManager) view.getContext()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                if (imm != null) {
                    imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
                }
            }
        }
    });
}

From source file:Main.java

public static void showInputKeyboard(Context context) {
    try {/*w  ww  . ja v a  2 s  . c o  m*/
        View view = ((Activity) context).getWindow().peekDecorView();
        if (view != null && view.getWindowToken() != null) {
            InputMethodManager imm = (InputMethodManager) context
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
            imm.showSoftInput(view, 0);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.mypopsy.widget.internal.ViewUtils.java

public static void showSoftKeyboardDelayed(final EditText editText, long delay) {
    editText.postDelayed(new Runnable() {
        @Override/*from   w  ww  . j  ava 2s.  c o m*/
        public void run() {
            InputMethodManager inputMethodManager = (InputMethodManager) editText.getContext()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            inputMethodManager.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
        }
    }, delay);
}

From source file:Main.java

public static void showSoftKeyBoard(Context context, View... views) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (views != null) {
        for (View view : views) {
            if (view != null) {
                imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
            }/*  w  w  w  .j  a va 2 s .co  m*/
        }
    }
}

From source file:com.justplay1.shoppist.utils.ViewUtils.java

public static void showSoftKeyboardDelayed(final EditText editText, long delay) {
    editText.postDelayed(() -> {//ww  w  .j  av  a2 s  .com
        InputMethodManager inputMethodManager = (InputMethodManager) editText.getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
    }, delay);
}

From source file:Main.java

private static void toggleSoftInput(Context context, View v, boolean hide) {
    if (context != null && v != null) {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (hide)
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
        else/* w  w w .  j ava 2 s . c o m*/
            imm.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT);
    }
}

From source file:com.tengio.util.Util.java

public static void showSoftKeyboard(final Context context, final EditText editText) {

    new Handler().postDelayed(new Runnable() {
        @Override// w  w  w  . j  av  a  2 s  . co  m
        public void run() {

            InputMethodManager inputMethodManager = (InputMethodManager) context
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            inputMethodManager.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
        }
    }, 100);
}

From source file:com.domowe.apki.lista2.Utils.java

public static void showKeyboard(Context context, EditText editText) {
    editText.requestFocus();/*from www  .j  a v  a2 s  . c o m*/
    InputMethodManager inputMethodManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
}