How can I resume the last viewed activity after the user has closed the application?

How can I resume the last viewed action after the user has closed the application. It looks like: if the user opens the application, the first action appears, and when the user clicks the button, he will go to the next action, if he closes the application and opens again, he will still show the last viewed action. how would i do that? please help me.

Thanks,

+4
source share
4 answers

I think you should use sharedpreferences. And in each event you open, you must put the value in your public access so that when you re-open the application, it checks the value of your general preferences, and then compare it, call the action that corresponds to the value you received. Hope this helps :)

+3
source

Here's what a quick search showed me. Hope this will be helpful!

How to return the android application to the last open action when you restart it? Android - restore last view Activity

Joseph quote in the first link:

To achieve the described, you can simply save the last visible action in SharedPreferences and have a Manager activity that launches the last action in accordance with the settings.

Look at the complete answer of Joseph - he is quite thorough

+1
source

Then you need to track its last action, save it in the database and whenever it returns, look at its latest activity in the database ... another way is cookies, but it is not recommended.

0
source

Put this line below in AndroidManifest.xml for your actions in <activity/> .

 android:launchMode="singleTask" 
0
source

Source: https://habr.com/ru/post/1488198/


All Articles