1

My problem is the following. When I start my application from the launcher, I want it to be always started from main activity, but only when it was cleaned from memory by android.

For example I have activities A (main activity) and B. When I launch my app and go to the B, and press home button, and just after this launch my app again, I want it to start B, like it do now. But if I press home button from B, and left the app in background for some time (or for example clean up memory manually with some memory cleaner app) and my activities get killed, I want my app to start again from main activity, not from activity B. How can I achieve this?

I browsed the net but the only thing I have found is clearTaskOnLaunch="true" declaration in manifest. But this is not what I want, because it starts app from main activity even if Android hasn't clean upped activities.

Andranik
  • 2,729
  • 1
  • 29
  • 45
  • Why do you need your app to lose the state when "home" is pressed? Right now I cannot imagine a use case for the behaviour you describe. – 18446744073709551615 Nov 13 '14 at 09:11
  • I don't want it to lose state when home is pressed, I want it to lose state only when it is in background for a long time and android has cleaned its activities. I need the onCreate method of my main activity to work every time the app starts after memory cleanup. – Andranik Nov 13 '14 at 09:19
  • @Andranik I have exactly the same problem. Did you find a solution? – Damnum Apr 20 '17 at 06:04
  • This is basically a duplicate of http://stackoverflow.com/questions/12363375/application-not-open-main-activity-when-it-was-killed-after-pressing-home-button/43516172#43516172 – David Wasser Apr 20 '17 at 09:58

0 Answers0