I meet this case, I check the soft keyboard is on and I want to dismiss in the code, when I use the below code it cannot dismiss the keyboard, because the code can not find any focus, but the keyboard is still on, so how can I hide it?
private void hideSoftKeyboard() {
    Activity activity = (Activity) sContext;
    View view = activity.getCurrentFocus();
    if (view != null) {
        InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
        //((Activity) sContext).getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    } else {
            Log.i(sClassTag,"focus not found");
    }
}
 
     
     
     
     
    