0

I'm developing a small aplication in Android with Android Studio. It is just a WebView that connects to a URL and shows a webpage in fullscreen mode. I don't need the software Keyboard so I disable it, but still shows a popup Keyboard in the bottom of my webview (See image). If I click it, the popup dissapears, but when a click in any part of the webview, it appears again. It doesn't show the keyboard in any case—just the pop up.

I can't edit the URL content.

How can I disable this pop-up permanently?

Pop up Keyboard

This is my AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="cl.archibaldo.floreantpos">

    <uses-permission android:name="android.permission.INTERNET" />
    <application
        android:theme="@style/AppTheme"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher"
        android:supportsRtl="true"
        >
        <activity
            android:name=".ActivityWebView"
            android:alwaysRetainTaskState="true"
            android:configChanges="keyboardHidden"
            android:screenOrientation="landscape"
            android:windowSoftInputMode="stateAlwaysHidden"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
        </activity>
        <activity android:name=".MainActivity"
            android:screenOrientation="portrait"
            >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

My activity_webview.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:descendantFocusability="blocksDescendants"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="cl.archibaldo.floreantpos.ActivityWebView">

    <WebView

        android:focusable="false"
        android:focusableInTouchMode="false"
        android:id="@+id/webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>
</LinearLayout>

And my ActivityWebView.java

package cl.archibaldo.floreantpos;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.WindowManager;
import android.webkit.WebView;

public class ActivityWebView extends Activity {

    WebView myWebView;
    View decorView;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Intent intent = getIntent();
        String url = intent.getStringExtra("URL");
        this.setContentView(R.layout.activity_webview);

        hideSystemUI();

        myWebView = (WebView) this.findViewById(R.id.webview);
        myWebView.getSettings().setJavaScriptEnabled(true);
        myWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
        myWebView.setSaveEnabled(true);
        myWebView.getSettings().setLoadWithOverviewMode(true);
        myWebView.getSettings().setUseWideViewPort(true);
        myWebView.loadUrl(url);

        decorView.setOnSystemUiVisibilityChangeListener
                (new View.OnSystemUiVisibilityChangeListener() {
                    @Override
                    public void onSystemUiVisibilityChange(int visibility) {
                        if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
                            Handler espera3segundos = new Handler();
                            espera3segundos.postDelayed(new Runnable(){
                                public void run(){
                                    hideSystemUI();
                                }
                            },3000);
                        }
                    }
                });


    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    private void hideSystemUI() {

        this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
        decorView = this.getWindow().getDecorView();
        decorView.setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
                        | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                        | View.SYSTEM_UI_FLAG_IMMERSIVE);

    }


}

Thanks in advance and sorry for my english. I still learning. Regards.

Arya McCarthy
  • 7,436
  • 3
  • 27
  • 48

1 Answers1

0

Add following code in main(parent) layout in your layout.xml

android:descendantFocusability="blocksDescendants"

and set following property in your webview.

android:focusable="false" 
android:focusableInTouchMode="true"
Vasant
  • 3,078
  • 3
  • 15
  • 31
  • This was answered here before : http://stackoverflow.com/a/29409478/3280468 – Amit Sharma May 19 '17 at 07:04
  • @AmitSharma Thanks for the reply. I tried with the answer you suggest, but it did not work. I want to disappear the pop-up keyboard that can be seen in the picture in my original post, only the message, since the keyboard is already disabled. – Archibaldo De La Cruz May 20 '17 at 02:25
  • @Vasant Indeed, that code disables the keyboard and clicking on it does not show anything. But pop up keeps popping up when I press anywhere on the screen. Thank you very much for your help. – Archibaldo De La Cruz May 20 '17 at 02:32