I have some fragments in my host activity. When I click the back button, it calls finish(), which closes the existing host activity and takes me to the previous activity. This behavior is expected.
However, in another scenario, if I completely close the app without clicking the back button and then reopen it, I find myself in the same expected fragment (splash screen -> fragment). Now, if I click the back button, it closes the host activity and takes me to the splash screen. This is not the desired behavior; I want it to return to the previous activity that was active before completely closing the app.
I believe I lost the activity stack after closing the app. How can I preserve this state?
I think when i am closing the app it is calling onDestroy() which is clearing the activity stack. is there any way so that i can save or restore the activity stack even after closing the app?
Before closing the app completely:
loginActivity->registerActivity->fragmant->Back Button Clicked->loginActivity | correct way
After closing the app completely:
splash screen->registerActivity->back button clicked->splash screen | incorrect way
splash screen->registerActivity->back button clicked->loginActivity | correct way