Trying to understand best practice for the lifecycle of my android application, and how activities fit into it.
For example, I have a main activity, sort of the “home” of my application. But, on start-up there are several activities that I ‘might’ need to run, depending on several cases, one being that it is the first time the app’s been run.
Is best practice to call these ‘start-up’/house-keeping activities FROM my ‘home’ activity? Or should the application begin with a ‘house-keeping’ activities, do the work, then finish() and start the ‘home’ activity?
Thanks for advice about this,
— J
I would set your
LAUNCHER<intent-filter>on whatever the user will most likely want to go to from their home screen. Presumably, that would be your “home” activity.In
onCreate()of that activity, make the determination if there is some other activity that is needed (e.g., “first-run”), and callstartActivity()on it. When the user presses BACK from there (or youfinish()that new activity), control will return to your “home” activity.