Android 4.0的WebView.loadURL怪胎 [英] Android 4.0 WebView.loadURL oddity

查看:154
本文介绍了Android 4.0的WebView.loadURL怪胎的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android应用程序,其中包括一个活动叫做帮助这将使用的WebView显示HTML格式的帮助内容。 Thie活动可以调用两种方法:将通过一个URL,或直接的文本内容。我曾经通过这个唯一的URL为file:///android_asset/help/index.html。(这是在APK包含在我的资产HTML页面)

I have an Android app which includes an activity called Help This uses a WebView to display the help content in HTML format. Thie activity can be invoked two ways: either passing a URL, or direct text content. The only URL that I ever pass to this is "file:///android_asset/help/index.html" (which is an HTML page included in my assets in the APK).

传递的网址正常工作在我的HTC Desire运行Android 2.2。这似乎也运行Android 3.0的模拟器工作研究。然而,当我尝试在Android 4.0的模拟器,它似乎尝试推出网络浏览器,而不是,显示空白页;当我关闭这个,我回到我的帮助的活动,也呈现出空白页。

Passing the URL works fine on my HTC Desire running Android 2.2. It also seems to work in an emulator running Android 3.0. However, when I try it in an emulator with Android 4.0, it seems to try to launch the Web browser instead, to display a blank page; when I close this, I am back in my Help activity, also showing a blank page.

直接传递文本内容的正常工作在所有我试过的版本。该的WebView 文档中说需要注意的是,为了让您的活动访问在一个web视图互联网和加载网页,你必须添加Internet的权限,以你的Andr​​oid清单文件:但我不需要访问Internet正因为如此,我只是想显示我的应用程序内部的帮助页面。而这之前,4.0曾在Android版本。

Passing direct text content works fine on all the versions I’ve tried. The WebView documentation says "Note that, in order for your Activity to access the Internet and load web pages in a WebView, you must add the INTERNET permissions to your Android Manifest file:" But I have no need to access the Internet as such, I just want to display my app-internal help page. And this has worked on Android versions prior to 4.0.

这是在安卓4.0的错误?或者是它只是我误解了?感谢您的帮助。

Is this a bug in Android 4? Or is it just something I’ve misunderstood? Thanks for any help.

推荐答案

我在上周更新从2.3.4到4.0我的HTC感觉。 这两个应用程序我写了一个本地的HTML接触部位。 在2.3它运行正常,现在我得到一个网页不可用的网站。

I updated last week from 2.3.4 to 4.0 on my HTC Sensation. The two apps i wrote had a local HTML-Contact site. On 2.3 it ran fine, now i get a "Webpage not available" site.

我发现了另一篇文章在这里在本网站的评论: 通过与谷歌的工程师一些讨论,似乎他们已经做出的立案决定://方案是不安全的

I found another post here on this site with the comment: "Via some discussion with a Google engineer it seems that they've made the decision that the file:// scheme is insecure."

下面参见:<一href="http://stackoverflow.com/questions/8390985/android-4-0-1-breaks-webview-html-5-local-storage">Android 4.0.1休息的WebView HTML 5本地存储?

这篇关于Android 4.0的WebView.loadURL怪胎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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