'How to go back to the last activity when the app is killed and reopened

I want my Android app to go back to the last activity if the user closes and reopens the app again. I search for some info, but most of them just save the data. I am wondering how to save the activity. For example, my app has two activities, the app was killed when it was in activity 2. When I relaunch the app, it should go to activity 2 instead of activity 1.



Solution 1:[1]

Use 1 Activity and 2 Fragment; then use Bundle savedInstanceState.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1