我正在尝试使用在 Android 中显示 PDF WebView,我正在google docs为此目的使用。直到今天早上它工作得很好。但是突然之间它抛出了502错误。有没有其他方法可以在WebView.
这是我用来呈现 PDF 的 URLWebView
https://docs.google.com/gview?embedded=true&url=+网址
好像https://docs.google.com/gview?embedded=true&url=下线了
我正在尝试使用在 Android 中显示 PDF WebView,我正在google docs为此目的使用。直到今天早上它工作得很好。但是突然之间它抛出了502错误。有没有其他方法可以在WebView.
这是我用来呈现 PDF 的 URLWebView
https://docs.google.com/gview?embedded=true&url=+网址
好像https://docs.google.com/gview?embedded=true&url=下线了
试试这个方法
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
if (url.endsWith(".pdf"))
{
// Load "url" in google docs
String googleDocs = "https://docs.google.com/viewer?url=";
mWebView.loadUrl(googleDocs + url);
}
else
{
// Load all other urls normally.
view.loadUrl(url);
}
return true;
}
更新试试这个
webview.loadUrl("http://docs.google.com/gview?embedded=true&url=" + url);