0

I've used webview to show a website in my application. This is my code:

final ProgressDialog progressBar;
    WebView wb=(WebView)findViewById(R.id.wb);
    WebSettings settings = wb.getSettings();
    settings.setDefaultTextEncodingName("utf-8");
    settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    settings.setSaveFormData(false);
    settings.setSupportZoom(true);
    settings.setJavaScriptEnabled(true);
    settings.setSaveFormData(false);
    settings.setSavePassword(false);
    progressBar = ProgressDialog.show(this, "","در حال دریافت اطلاعات");

    wb.setWebViewClient(new WebViewClient(){
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
        public void onPageFinished(WebView view, String url) {
            if (progressBar.isShowing()) {
                progressBar.dismiss();
            }
        }
    });

    Bundle bl=getIntent().getExtras();
    wb.loadUrl("http://mysite");

It loads the website correctly, but it has lot of menus and some part doesn't work. These parts works fine in the mobile browser but doesn't work in the webview of mine.

I think part of the code are javascript or jquery and they are not working properly in webview.

How can I fix this?

Raja Jawahar
  • 6,742
  • 9
  • 45
  • 56
Navid Abutorab
  • 1,667
  • 7
  • 31
  • 58

2 Answers2

0

Add in your webview

    wb.setWebChromeClient(new WebChromeClient()); 
sasikumar
  • 12,540
  • 3
  • 28
  • 48
  • sir did your read this question i think he already using **`wb.setWebViewClient(new WebViewClient()`** – AskNilesh Jul 05 '18 at 04:10
  • refer this..it will be helpful for you https://stackoverflow.com/questions/5089578/enabling-general-javascript-in-webviewclient – sasikumar Jul 05 '18 at 04:15
0

PFB for for webview in android

webView=(WebView)findViewById(R.id.webView);
        WebSettings webSettings=webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webView.loadUrl("https://google.in");
        webView.setWebViewClient(new WebViewClient());//by using this method webpage open in your app 
Divyanshu
  • 462
  • 6
  • 17