Search code examples
androidexitlifecycle

Android: Lifecycle problem - leaving the application


The first activity in my app is a splash screen with a Progress Dialog in which I load data from a Web Service.
When this is done I start the next activity and call finish() in the first activity's onPause(), in order for it to not appear again.
The next activity is my main menu and on from there I browse the application.
The problem is when I want to leave the application. I return to the main menu from whichever activity I have been to and press BACK or HOME.
If shortly after I launch the app again, my main menu immediately appears and I do not go through the splash screen where the data is brought over. Also, it seems that the data held prior to leaving was released. As a result, the activities I launch from the main menu (which depend on the data fetched during the splash screen) turn up empty.

Does anyone have an idea how to go about this?
Thanks, Rob


Solution

  • Do you store your data in the bundle that get's loaded by onCreate() when leaving your main activity?

    I would recommend to read the section about Saving activity state on http://developer.android.com/guide/topics/fundamentals.html