1

If app is put to background and then GC'ed because of low RAM I would like the app to restart from the first activity and not the activity it was in before it was put to background.

I know I could NULL checks for certain objects and if they are I would just start the first activity with clear top added.

I am looking for a more elegant way

tomi
  • 525
  • 9
  • 20
  • Why do you want to? A process being terminated for resources and then later restarted when one of the app's activities comes back to the foreground is meant to be an invisible implementation detail to the user. You should have your app restore the state that the user was in when they left. – adamp Mar 18 '12 at 17:37
  • because then the connection to server along with the credentials is severed. So the user is required to relogin – tomi Mar 18 '12 at 17:52
  • You should obtain some form of session token from the server on initial login that you can use to reconnect transparently when the app's process is restarted. Asking the user to relogin "randomly" (what you propose will appear inconsistent/random to the user) would be a poor user experience. – adamp Mar 18 '12 at 17:57
  • what about in the scenario where one has plenty of singleton as is the case here. And this singletons are filled throughout the app? http://stackoverflow.com/a/3827166/1143354 It would be kinda hard trying to save everything everytime onPause happens. – tomi Mar 20 '12 at 09:40
  • If you have a ton of singletons with state that you can't possibly persist that would need to be persisted in order to properly restore your application's user-visible state, you're doing something very wrong. – adamp Mar 21 '12 at 05:33

0 Answers0