Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
238 views
in Technique[技术] by (71.8m points)

java - Android 4.0 WebView.loadURL oddity

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).

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.

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.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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."

See here: Android 4.0.1 breaks WebView HTML 5 local storage?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...