not working in webview

As per your expectation, I think you want to enable heavy task in your WebView. For that you need to enable ChromeClient,

mWebView.setWebChromeClient(new MyWebViewClient());

And your MyWebViewClient class will be,

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mWebView = (WebView) findViewById(R.id.activity_main_webview);

        // Force links and redirects to open in the WebView instead of in a browser
        mWebView.setWebViewClient(new WebViewClient());
        mWebView.setWebChromeClient(new MyWebViewClient());    // HERE

        // Enable Javascript
        WebSettings webSettings = mWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);

        // Use remote resource
        // mWebView.loadUrl("http://example.com");

        // Stop local links and redirects from opening in browser instead of WebView
        // mWebView.setWebViewClient(new MyAppWebViewClient());

        class MyWebViewClient extends WebChromeClient {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                super.onProgressChanged(view, newProgress);
            }
    
            @Override
            public void onReceivedTitle(WebView view, String title) {
                super.onReceivedTitle(view, title);
            }    
        }

        // Use local resource
        mWebView.loadUrl("file:///android_asset/www/index.html");
    }

Leave a Comment