1

Possible Duplicate:
How to make an android app return to the last open activity when relaunched?

I'm converting my iOS App to Android. In iOS I used NSUserDefaults to save the last view used so it will return on that view after the app has been closed. For Android I would like to do the same.

This is what I'm trying to achieve:

User navigates to a specific Activity > App saves activity in memory > User quits App > User Starts App again > User sees the last used activity again.

Where should I start looking for? Is there a simple way to achieve my goal?

Community
  • 1
  • 1
user1839995
  • 113
  • 2
  • 9

2 Answers2

0

Generally this functionality just happens in Android because of the way the system manages Activities and memory, though if the app gets killed then it will start over at whatever the default Activity is.

To ensure the restart of a specific Activity, I'd probably use SharedPreferences and just store a key value in there designating the Activity to start. Then in the default Activity, I'd have it check for that key in the SharedPreferences when it starts, and if it exists, start the specified Activity.

Khantahr
  • 8,156
  • 4
  • 37
  • 60
0

Yes,you can save last activity's name in the shared preferences. It is nicely explained here.

Hope this will solve your problem :)

Community
  • 1
  • 1
AndroidLearner
  • 4,500
  • 4
  • 31
  • 62