The keyboard does not close after returning from the mail client

I have an Android app that contains a list of products via email. I had problems when after sending the list by the mail client (it can be an exchange client or a Gmail client) the keyboard will not be closed.

I tried:

InputMethodManager mgr = (InputMethodManager) getSystemService(
        Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(editTxt.getWindowToken(), 0);

and many other ways. If I check if the keyboard is open, it will return false, since it is not a keyboard calling application, but an email client.

I found a workaround, including:

android:windowSoftInputMode="stateAlwaysHidden"

then the application will forcefully close the keyboard, but will continue to lag every time I open the keyboard again.

With a Samsung phone, the problem exists only if I use the Gmail client.

+5
3

. (Email-) editText. . , :

Timer timer = new Timer();
timer.schedule(new TimerTask() {

            @Override
            public void run() {
                closeKeyboard();
            }
        }, 20);
+2

android:windowSoftInputMode="stateHidden" activity

0

Do you put this code in the onResume () method ?

0
source

All Articles