我正在尝试从Android Marshmallow中的链接加载pdf文件。它始终显示空白屏幕,而代码工作正常,版本低于6.0。请帮忙。 感谢
以下是我正在使用的代码
webView = (WebView)findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
webView.loadUrl ("http://drive.google.com/viewerng/viewer?embedded=true&url="+url);
return super.shouldOverrideUrlLoading(view, url);
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
// showProgress(LoadPageByUrlActivity.this,"Please wait...");
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url)
{
super.onPageFinished(view, url);
// stopProgress();
}
});
String url = getIntent().getExtras().getString("url");
if(url.contains("pdf")){
webView.loadUrl("http://drive.google.com/viewerng/viewer?embedded=true&url="+url);
}else
webView.loadUrl(url);
}