Aravind
Aravind

Reputation: 590

Android - Maintaining webview state across activities

I've read multiple similar posts but have not found a working solution for this problem.

I have two activities A and B. Activity B is launched from Activity A (when I click a button in Acitvity A). Activity B loads a url which displays a map.

The problem is that, when I navigate away from Activity B and come back to it, the webview loads the URL again. Is there way to kind of maintain the state of the webview as is so that it does not load the url again.. I've seen posts hinting at onSaveInstanceState but I havent been successful getting this work.

Can someone please post some psedo/sample code?

Thanks in advance!

Upvotes: 0

Views: 744

Answers (1)

Aravind
Aravind

Reputation: 590

I've solved this problem using Fragments: Fragments Show/Hide

I could not find a way to maintain the state of webview (so that it does not requery the url) when I navigate away from a webview to another activity and navigate back to the webview - It alway reloads the url.

I found the fragment approach much better. Fragments was introduced in Android Honeycomb but for earlier versions you can you the support package : Comatibility Package

Upvotes: 1

Related Questions