Keyboard is opening with bottom sheet dialog fragment without even having EditText in Activity or Fragment

Viewed 67

I don't know why but Keyboard automatically opens when I open BottomSheetDialogFragment from another fragment. I tried with both navigation component and old method. I tried on API 24, 27, 30. On API 30 its working fine but in 24 and 27 facing this issue. Anyone here who is facing this issue? And Anyone who have solution for this problem please post answer.

1 Answers

this is not the best way to do that but you can use this code to disable the keyboard in your onActivityCreated function in a fragment:

InputMethodManager i = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
i.hideSoftInputFromWindow(getView().getWindowToken(), 0);

it is better to find the cause of why the keyboard comes up automatically but you can use this solution if you want.

Related