Code example for InputMethodManager

Methods: hideSoftInputFromWindow, isActive

0
     *            a {@link android.view.View} object. 
     */ 
    public static void dismissVirtualKeyboard(Context context, View view) {
 
        InputMethodManager inputManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (inputManager.isActive(view))
            inputManager.hideSoftInputFromWindow(view.getApplicationWindowToken(), 0);
        // inputManager.showSoftInput(ourCanvasInstance, 0); 
        // inputManager.hideSoftInputFromInputMethod(this, 0); 
        // && inputManager.isFullscreenMode() 
        // if(inputManager.isActive()) 
        // { 
        // inputManager.toggleSoftInput(0, 0); 
        // } 
    } 
 
    public static boolean isHoneycomb() { 
        // Can use static final constants like HONEYCOMB, declared in later versions 
        // of the OS since they are inlined at compile time. This is guaranteed behavior. 
        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
    }