I have various pieces of generated HTML/JS that I load into Activity with WebView#loadDataWithBaseURL. Is there a way to not load in again and again during Activity lifecycle? For example - user goes to check the message and then calls the app again. At that point - the Activity is stopped and probably destroyed, when it's loaded again I do not want to hiccup on loading the content user was already viewing.
+2
A:
For example - user goes to check the message and then calls the app again. At that point - the Activity is stopped and probably destroyed
If the user directly visited the Notification
, or clicked HOME, your activity is stopped but not destroyed. In these cases, your WebView
should not change content unless you change it.
Your activity will be destroyed if the user presses BACK, or Android needs to close you out because of memory constraints.
In the BACK case, the user is expressly telling you to go away, so reloading your data seems reasonable.
In the memory-constraint way, by definition the device is short on memory, so you're going to need to reload the data if and when you are brought back to the foreground.
CommonsWare
2009-09-10 10:41:11
I just want to note that I always get onCreate call when app is restored after "Home" was clicked. It is mighty annoying that WebView does not support history for HTML loaded with data calls
DroidIn.net
2009-09-14 00:10:17
With respect to your onCreate(), something on your phone is leaking memory like a sieve, or you are expressly calling finish() in your onPause()/onStop() code, or something else is happening that is causing your activity (or process) to be destroyed and then restarted. Or, perhaps you have flags set in your manifest to require new tasks to be started every time.
CommonsWare
2009-09-14 10:27:14