如何在android浏览器中打开pdf文件?
我有本地pdf文件的链接html页面。我想在浏览器(chrome、opera、dolphin)中打开此pdf文件,而无需活动的internet连接。你知道这个插件吗?它可以在浏览器、方法或其他东西中打开pdf文件(无需下载)?我曾经用过的一个解决方案是用谷歌文档打开它们如何在android浏览器中打开pdf文件?,android,pdf,browser,Android,Pdf,Browser,我有本地pdf文件的链接html页面。我想在浏览器(chrome、opera、dolphin)中打开此pdf文件,而无需活动的internet连接。你知道这个插件吗?它可以在浏览器、方法或其他东西中打开pdf文件(无需下载)?我曾经用过的一个解决方案是用谷歌文档打开它们 _webView.loadUrl("https://docs.google.com/gview?embedded=true&url="+ url); 使用以下代码: CustomWebView webView = (C
_webView.loadUrl("https://docs.google.com/gview?embedded=true&url="+ url);
使用以下代码:
CustomWebView webView = (CustomWebView) rootView.findViewById(R.id.webView);
webView.loadUrl("https://docs.google.com/gview?embedded=true&url=" + yourUrl);
按如下方式创建CustomWebView类:
public class CustomWebView extends WebView {
private Context context;
private ProgressDialog progressDialog;
public CustomWebView(Context context) {
super(context);
this.context = context;
init();
}
public CustomWebView(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
init();
}
public CustomWebView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.context = context;
init();
}
private void init() {
setWebSetting();
}
private void setWebSetting() {
WebSettings webSettings = getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setPluginsEnabled(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
webSettings.setLightTouchEnabled(false);
setScrollBarStyle(SCROLLBARS_OUTSIDE_OVERLAY);
setWebViewClient(new CustomWebViewClient());
}
class CustomWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
progressDialog = ProgressDialog.show(context, null,
context.getString(R.string.msg_please_wait));
progressDialog.setCancelable(false);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
progressDialog.dismiss();
}
}
}
不幸的是,Android设备上的本机浏览器不支持这种类型的文件。让我们看看在4.0+中我们是否能够做到这一点。向我们展示您迄今为止所做的研发工作。你试过搜索Stackoverflow本身吗?我在找第二个星期。但是docs.google不适合(需要主动连接),一套插件(perfect viewer pdf,kingsoft office e.t)无助于解决问题。如果没有主动连接到internet,如果没有主动连接到internet,您需要主动连接到internet才能使用此方法。支持哪些类型的文件?