android: Android Webview cannot render the pdf sometimes and shows blank/white page instead

Steps to Reproduce

  1. Open the pdf in the webview using google docs link.
  2. Open the same pdf or different pdf again and again.
  3. Sometimes it will show the blank/white page in the android untill we refresh the webpage again for 1 or 2 times.

Code

public void SetWebView(WebView webview,string externalUrl){
			webview.Tag = "webview";
			webview.Settings.JavaScriptEnabled = true;
			webview.Settings.SupportZoom ();
			webview.Settings.SetAppCacheEnabled(true);
			webview.Settings.DomStorageEnabled = true;
			webview.ZoomOut ();
			webview.ZoomIn ();
			webview.Settings.BuiltInZoomControls = true;
			webview.Settings.LoadWithOverviewMode = true;
			webview.Settings.UseWideViewPort = true;
			//webview.Settings.SetSupportZoom (true);
			webview.Settings.SetPluginState (WebSettings.PluginState.On);
			webview.Settings.GetPluginState ();
            if (externalUrl.StartsWith("http://") || externalUrl.StartsWith("https://"))
                webview.LoadUrl (externalUrl);
			webview.SetWebViewClient (new MonkeyWebViewClient (imgViewBack, imgViewForward, imgRefresh));
			webview.SetWebChromeClient (new WebChromeClient ());
		`}`

Screenshot_20190416-132946 1

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 2
  • Comments: 16 (4 by maintainers)

Most upvoted comments

If you’re getting the same problem in Android Studio, that means it’s probably just a general problem with Android, sorry 😞 .

I think you should try posting on either:

Closing for now, since I don’t think it’s an issue with Xamarin.Android, but let us know otherwise, thanks!

I was able to solve this https://medium.com/@mr.kante416/pdf-in-webview-android-1380de57155c shared in this article now well written will update in some time.

Same issue with me also

I will try to create a small application to reproduce the same issue. As per your need I send the information about the environment below:

  • Xamarin.Android Version => 2.5144934
  • Operating System => Windows
  • IDE Version => Microsoft Visual Studio Community 2017 Version 15.9.2
  • Android Version - 26
  • I checked it only on device in fact on 3 or more devices.

Hello, @gopalawasthi123

Would you mind creating a small application to reproduce the issue? We’d also need more information about your environment, specifically:

  • Your Xamarin.Android version
  • Your operating system
  • Your IDE version
  • Android version you run the application on
  • Does it happen on device, in the emulator, both?

Thanks!