1

Here are the scenarios.

Scenario #1: My android app goes into the background because a user hit the "home" button. The user then immediately comes back to the application and the app picks up at the last activity and retains it's history stack and /onResume is called. Cool. All very expected behavior.

Scenario #2: My android app goes into the background because a user hit the "home" button. The user waits a considerable about of time before coming back to the app. A new instance of the app the "Application" class /onCreate is called and the app goes back to the last activity that was on the screen and retains the history stack. This is exactly like Scenario #1 except the Application.onCreate has been called.

While Scenario #2 is true, it's unexpected behavior to me. If a new instance of the app is launched because the OS wanted to reclaim memory, I would expect my "MAIN" launcher to be called, NOT the last activity and I would also not expect a history stack.

Question: I want the behavior in Scenario #1, but in Scenario #2 when a new instance of the app is created how can I make it launch a new/fresh version of the app?

Thanks guys for all the help.

user123321
  • 12,593
  • 11
  • 52
  • 63
  • for me this is very expected behavior... And thas is the cause why we SHOULD NOT store "static data" in Application instance – Selvin Oct 15 '12 at 21:07
  • thank you for your feedback. I will still consider the issue open as it's very common, for example in a game, to have a "loading" screen to load heavy assets which are accessed in a "static data" way. If the app has been killed because its in the background, the app should go through the loading process again when it relaunches. – user123321 Oct 15 '12 at 21:42
  • My bad, persist or global could be better word, anyway, why dont you load this data in Application again in onCreate? – Selvin Oct 15 '12 at 21:48
  • 1
    Or check this http://stackoverflow.com/questions/11243019/application-restart-activity-entry-point – Selvin Oct 15 '12 at 21:54
  • Thank you for confirming. If you'd like to move this link down below I can mark the issue as resolved and accepted! – user123321 Oct 15 '12 at 22:00

1 Answers1

0

Urgh...I can't mark a comment as the answer and "small answers" are automatically converted to a comment. So here is random text. The answer is in the link below.

Application restart - Activity Entry Point

Community
  • 1
  • 1
user123321
  • 12,593
  • 11
  • 52
  • 63