i'm trying to prevent the keyboard from showing up after calling requestFocus() on a SearchView but there is no solution to fix that on Android 8.
i tried :
/*1/
android:windowSoftInputMode="stateAlwaysHidden" /*2/
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); /*3/
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); if (activity.getCurrentFocus() != null && activity.getCurrentFocus().getWindowToken() != null) inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); /*4/
final View activityRootView = findViewById(R.id.rootLayout); activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { int heightDiff = activityRootView.getRootView().getHeight() - activityRootView.getHeight(); if (heightDiff > dpToPx(Act_StoreOrder.this, 200)) { // if more than 200 dp, it's probably a keyboard... Log.i("<<<Clavier","Clavier Showed Up"); //hide here } } }); onGlobalLayout() worked but the softkeyboard show up for nearly 0.5s and disappear.
Any help to make that softkeyboard hidden even after calling requestFocus() ??