Soft keyboard remains after launching webview

I have an application that logs into a web application using some credentials. Login initiates web browsing.

Here's the problem.

In emulator (Nexus_S_Google and Nexus 5 with API 21) and Samsung tablet, keyboard disappears when webview appears. This would be the desired behavior. On two different phones (Samsung 5s and Samsung Galaxy Note 5) the keyboard does no . Is this exactly how phones work? Or is there a way to trigger this behavior? I don't understand why this works on tablet and emulator but not on phones.

Here's what I've tried.

In the manifesto.

android:windowSoftInputMode="adjustPan">

      

In XML operation

android:focusable="true"
android:focusableInTouchMode="true"/>

      

In MainActivity after the webview gets the url.

webView.requestFocus();

      

+3


source to share


1 answer


Ok, it took a long time, but this is what I did to fix the problem.

Created method

private void fKeyboardClose()
    {
        InputMethodManager inputMethodManager = (InputMethodManager)getSystemService( Activity.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow( this.getCurrentFocus().getWindowToken(), 0);
    }

      



Then I named it right after the onClick button for the submit button.

submit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                fKeyboardClose();

                textstring(phone, login, pass);
                prefwrite(editor);
                pushurl();
                clear(phone, login, pass);

      

0


source







All Articles