加载网址Web视图的android - Java的 [英] Load url web view android - Java

查看:119
本文介绍了加载网址Web视图的android - Java的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序网页视图,我得到了它的工作是这样

I have a webview in my app and I got it working like this

webview = (WebView) findViewById(R.id.mainWebView);
webview.loadUrl("https://www.google.com");

但是,如果我尝试加载的非移动版 https://uniondining.sodexomyway.com/Images/MAR2015dutchCalendar_000_tcm1792-59025.pdf 退出出来的应用程序。

如何在我的应用程序加载网站的移动版本?

How can I load the mobile version of site in my app?

感谢

推荐答案

不幸的是,Android不支持在网页视图中查看PDF开箱。幸运的是,谷歌有一个漂亮的小工具,它可以让你很容易地执行这个任务非常使用谷歌文档。基本上,我们将嵌入我们的PDF在即时谷歌一个网页文件并加载。

Unfortunately, Android does not support viewing PDFs out of the box in a WebView. Luckily, Google has a nifty little tool that allows you to perform this very task quite easily using Google Docs. Basically we will embed our PDF in a Google Doc page on-the-fly and load that.

您可以使用谷歌文档查看器来读取你的PDF在线:
这里的code:

You can use Google Docs Viewer to read your pdf online: Here's the code:

WebView webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true); 
String pdf = "http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf";
webview.loadUrl("http://docs.google.com/gview?embedded=true&url=" + pdf);

如果您使用的视图仅URL中的用户没有propted登录到有Google帐户。

If you use the view only url the user is not propted to login to there google account.

这篇关于加载网址Web视图的android - Java的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆