1

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.

Lawrence D'Oliveiro
  • 2,768
  • 1
  • 15
  • 13
  • Have you tried if it works when you have the INTERNET permission? – Ilkka Feb 09 '12 at 06:04
  • I don’t really want to add that, since I have already published the app without INTERNET permission. It’s a good idea to avoid adding permissions willy-nilly to apps, is it not: we want to teach Android users to be suspicious about the permissions that apps require, rather than just blindly clicking “Accept” on everything. – Lawrence D'Oliveiro Feb 09 '12 at 06:13
  • Sure, I was just interested in whether it made a difference or not. – Ilkka Feb 09 '12 at 20:39

1 Answers1

1

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?

Community
  • 1
  • 1
  • 1
    The workaround works although you have to put the whole html into a string and escape every html-quote. Don't waste your time putting it into a string (in string.xml), because the XML-file gets malformed. – ChristianVK Apr 04 '12 at 17:49
  • Thank you for confirming that I’m not the only one seeing this, and that it’s a feature, not a bug. :) – Lawrence D'Oliveiro Apr 22 '12 at 01:33
  • Worst feature ever, probably intended to encourage people to write native android apps instead of html apps packaged in apks... Thankfully windows 8 will come out soon o_o – fabspro Jun 20 '12 at 16:58