Question

I'm creating a "Daily ...." application for Android. (Let's say "Daily flowers") The idea is: you get a notification each day and when you click it, it will show you a picture of a flower + some text. I'd like to distribute this from a website.

I can just create a notification that and an Intent to an activity with a WebView that does a loadUrl. However, this is far too slow! (takes between 1 and 5 secs depending on the network.)

So I would like to prefetch the "entire site" (1 HTML file, 1 image) and then create the notification so the application can show the daily flower in a snappy way.

Can this be done easily? I could do this the hard way with HttpClient etc, but I'd rather use something like WebView.saveState

Was it helpful?

Solution

I tried saveState and store the resulting bundle to a file. That didn't work well, because it only saves the meta-state (history, loaded url, etc) and not the actual contents (html, images).

The solution I ended up using is a server side hack: include all the images as base64 encoded entities in the html file. This way you can use the downloadManager and show the downloaded file in a WebView. Naturally, this only works when you have full control over the server as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top