1

I got a problem with the WebView I wrote: for some reason, the top bar doesn't render to the WebView but it works in the chrome browser. Here is an example of what I get:Mobile WebView

And this is what I should get:Chrome

This is my webSettings:

        webview = findViewById(R.id.webView);
    webview.setWebViewClient(new MyWebViewClient(this));
    url = getIntent().getStringExtra("URL");

    WebSettings webSettings = webview.getSettings();

    webSettings.setJavaScriptEnabled(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setSupportMultipleWindows(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setSupportZoom(false);
    webSettings.setAllowContentAccess(true);
    webSettings.setBuiltInZoomControls(false);

    webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    webSettings.setAppCacheEnabled(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setAllowFileAccess(true);

    webSettings.setEnableSmoothTransition(true);

and this is MyWebViewClient Class:

 public MyWebViewClient(Activity activity) {
    super();
    myActivity = activity;
    progressBar = activity.findViewById(R.id.progressBar);
}

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    try {
        Uri uri = Uri.parse(url);
        if(url.contains("https://www1.isracard.co.il/mobile_landing")){
            view.loadUrl("https://mservices.rafael.co.il:4443/mobile/giftcard/main.html");
            return false;
        }
        if(url.contains("sms:"))
        {
            Intent smsIntent = new Intent(Intent.ACTION_SENDTO,uri);
            //  smsIntent.setType("vnd.android-dir/mms-sms");
            //  smsIntent.setData(uri);
            view.getContext().startActivity(smsIntent);
            return true;
        }
        if (url.contains("tel:")) {
            Intent callIntent = new Intent(Intent.ACTION_DIAL);
            callIntent.setData(uri);
            view.getContext().startActivity(callIntent);
            return true;
        }
        if (url.contains("mailto:")) {
            Intent callIntent = new Intent(Intent.ACTION_SENDTO);
            callIntent.setData(uri);
            view.getContext().startActivity(callIntent);
            return true;
        }
        if (uri.getHost().contains("google") || uri.getScheme().contains("waze") || url.contains("mailto:") || url.toLowerCase().contains("newpage=true")) {
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            view.getContext().startActivity(intent);
            return true;
        }
        if (uri.getHost().toLowerCase().contains("youtube")) {
            Intent intent = new Intent(Intent.ACTION_CHOOSER, uri);
            view.getContext().startActivity(intent);
            return true;
        }
    } catch (Exception ex) {
    }
    return false;
}

@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
    super.onPageStarted(view, url, favicon);
    webViewPreviousState = PAGE_STARTED;
    // dialog = ProgressDialog.show(view.getContext(), "", view.getContext().getString(R.string.progressLoading), true, true);

}

@Override
public void onPageFinished(WebView view, String url) {

    progressBar.setVisibility(View.INVISIBLE);


}

What WebView setting I need to add in order to get the same result?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
avihaiB
  • 81
  • 1
  • 9
  • try adjusting margins – sak Jun 28 '20 at 09:55
  • or check this https://stackoverflow.com/questions/8012936/android-webview-cuts-off – sak Jun 28 '20 at 09:55
  • I just want to say that this up bar has a javascript or css on it and he is fading when u scroll down on a regular chrome, in my webview it doesnt appear at all for some reason, but at one page where the bar is static and not fading I can see him from the WebView – avihaiB Jun 28 '20 at 10:28

0 Answers0