gau*_*mar 5 android google-docs webview
使用google doc链接在android中的webview中打开pdf: -
webView.loadUrl("http://docs.google.com/gview&embedded=true&url=" + getIntent().getStringExtra(CONSTANT.pdfurl));
Run Code Online (Sandbox Code Playgroud)
对于一些pdf
"no preview availbale"
Run Code Online (Sandbox Code Playgroud)
发生在webview中,对于某些pdf它总是发生,我知道这个问题已被多次询问并且已经看到所有的stackoverflow和互联网但是找不到任何令人满意的解释.
如何知道在谷歌文档中查看pdf时何时"无法预览"以及如何解决此问题
进度条自动停止,有时不显示任何内容
这是我的完整执行代码: -
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
progressBar.setVisibility(View.VISIBLE);
webView.loadUrl("http://docs.google.com/gview&embedded=true&url=" + getIntent().getStringExtra(CONSTANT.pdfurl));
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
progressBar.setVisibility(View.VISIBLE);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return false;
}
@Override
public void onPageFinished(WebView view, String url) {
// do your stuff here
progressBar.setVisibility(View.GONE);
webView.setVisibility(View.VISIBLE);
}
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
view.loadUrl("about:blank");
Toast.makeText(getApplicationContext(), "Error occured, please check newtwork connectivity", Toast.LENGTH_SHORT).show();
super.onReceivedError(view, errorCode, description, failingUrl);
}
});
Run Code Online (Sandbox Code Playgroud)
我确定知道的一件事是,在http网站上它比https网站更频繁地发生.如何解决这个问题?
有没有办法在不更改网站的情况下将网址从http转换为https?
检查您的 pdf 路径,可能会为 null ( https://docs.google.com/gview?embedded=true&url=null )
或者使用意图打开pdf我发现很容易
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(pdf_url));
startActivity(browserIntent);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2713 次 |
| 最近记录: |