My application has 4 activities. If the user clicks the home button, the next time the application is launched, I want it to start on the main activity not the last activity it was on. If the phone's display turns off, as long as the application hasn't been closed, I want it to resume where it left off. What is the proper way to go about this?
This is the default launch mode of activity (If not specified). It launches a new instance of an activity in the task from which it was launched. Numerous instances of the activity can be generated, and multiple instances of the activity can be assigned to the same or separate tasks.
Typically, one activity in an app is specified as the main activity, which is the first screen to appear when the user launches the app. Each activity can then start another activity in order to perform different actions.
There are four types of launch modes in Android: Standard. SingleTop. SingleTask.
Just set clearTaskOnLaunch="true"
in your manifest main activity declaration.
http://developer.android.com/guide/topics/manifest/activity-element.html#clear
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With