获取InputMethodManager对象:
InputMethodManager imm = (InputMethodManager) getSystemService(Service.INPUT_METHOD_SERVICE);
切换打开/隐藏状态
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
打开键盘
imm.showSoftInput(view,InputMethodManager.SHOW_FORCED);
隐藏键盘
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
获取输入法状态
boolean isOpen=imm.isActive();