Is it possible to configure an android app so that if a user has opened your app, launched numerous activities, then returns to the home screen and relaunches your app again, instead of going to the main activity they will instead be taken to the activity highest on the stack (the most recent activity in your app)?
Android – How to make an android app return to the last open activity when relaunched
android
Related Topic
- Android – How to stop EditText from gaining focus at Activity startup in Android
- Android – Removing an activity from the history stack
- Android – How to create a transparent Activity on Android
- Android – How to prevent multiple instances of an Activity when it is launched with different Intents
- Android – Dialog throwing “Unable to add window — token null is not for an application” with getApplication() as context
- Android – Why fragments, and when to use fragments instead of activities
- Java – Need help in latent semantic indexing
Best Answer
When launched via icon on the home screen, Android will always start the activity with the
android.intent.action.MAIN
filter in yourAndroidManifest.xml
, unless the application is already running (in which case it will obviously restore the activity on top of the stack).To achieve what you described you can simply store the last visible activity in
SharedPreferences
and have a Dispatcher activity that starts the last activity according to the preferences.So in every activity you want to re-start automatically:
And a Dispatcher activity similar to the following:
Remarks
onPause
overrideandroid.intent.action.MAIN
action