iOS 4.2+ allows certain webapps to run in the background, without any special requirements.
How is it possible to run a webapp in the background on Android (to continue p
This is not really an answer, but wouldn't it be great though, if we could request a webpage to continue running in the background. Of course the page should need an explicit (and at all time revokable) consent from the user, but that doesn't seem like a completely impossible thing to handle for the (native) browsers? :( We already prompts the users for permission to use other APIs like the location API - why not also a run-as-a-service API?
It would be such a huge step forward for all webapps to be equal to native apps in my opinion! <3
As Robby said, to do this you need to use a Service.
Obviously you can't have a "background web page" just like you can't have one of those with any browser. The solution is to use WebView's setJavascriptInterface() to create an interface between your background service and HTML5/JS front-end in the WebView. With a javascript interface, you can create your own bindings to call into Java code from inside of your javascript.
The service can be used to preserve the background functionality, but when the app comes back into the foreground the WebView needs to bind to it via javascript interface again, get the data it needs, and populate its UI.
That is done by using background Services.