public class SoftKeyBoardUtil {
public static void openKeyBoard(final Context context, final EditText editText) {editText.setFocusable(true);editText.setFocusableInTouchMode(true);editText.requestFocus();Timer timer = new Timer();timer.schedule(new TimerTask() {public void run() {InputMethodManager inputManager =(InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);inputManager.showSoftInput(editText, 0);}}, 300);}public static void closeKeyBoard(final Context context, final EditText editText) {InputMethodManager inputManager =(InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);inputManager.hideSoftInputFromWindow(editText.getWindowToken(), 0);}public static void toggle(Context context) {InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);}
public static boolean isKeyBoardOpen(Context context) {InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);return imm.isActive();}
}