I am using the google docs pdf embedded viewer in my android app to display my pdfs. Sometimes the viewer doesn't load my file even though most of the time it does and it's pretty random when it doesn't.
I generate the url with "https://docs.google.com/viewer?embedded=true&url=" + myUrl.
And after that I load the webview :
showLoader()
web_view.settings.javaScriptEnabled = true
web_view.clearCache(true)
web_view.webViewClient = object : WebViewClient() {
override fun onPageFinished(view: WebView?, url: String?) {
hideLoader()
}
override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
web_view.loadUrl(url)
return true
}
override fun onReceivedSslError(view: WebView, handler: SslErrorHandler, error: SslError) {
println("before handler")
handler.proceed()
println("after handler")
}
}
web_view.loadUrl(url)
I tried to proceed if I encounter any sslError, to override urlLoading but none of this resolved my problem.
To test here is one of the url which doesn't always load :
http://docdif.fr.grpleg.com/general/MEDIAGRP/NP-FT-GT/LE10061AA.pdf
One thing I tried too is show the url when display on my app and when it doesn't load on my viewer it blocks too on my navigator. But if I reload the page it does charge.
Any idea what the bug might be?
Try this:
public void onPageFinished(WebView view, String url) {
if (view.getTitle().equals(""))
view.reload();
}
I hope that it can help you!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With