/**
* 隐藏键盘
*
* @param context
* @param view
*/
public static void hideSoftInput(Context context, View view) {
InputMethodManager imm = (InputMethodManager) IMApp.getAppContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (view == null) {
imm.toggleSoftInput(0, InputMethodManager.RESULT_HIDDEN);
} else {
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); //强制隐藏键盘
}
}
/**
* 判断输入法是否显示
*
* @param context
* @return
*/
public static boolean getSoftInputState(Activity context) {
return context.getWindow().getAttributes().softInputMode == WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED;
}