0

I have an application which always has to start with a splash screen.

But after the splash screen, I want that it should go to the last activity that was visible before the application went to the background.

Also, I would like the same behaviour when the app icon is clicked. So lets say the user was on Activity5 and then he pressed the Home button. Now if he clicks on the App icon, then the app should start with the Splash screen but then return back to Activity5.

Could someone please help me with the above?

Thanks and regards, Sunny

Sunny
  • 7,444
  • 22
  • 63
  • 104
  • I am not sure for this solution but you can hold current activity's name in shared preferences. When user click back button or app icon , you can intent the activity which names hold in shared preferences. Sorry for my English , I am not native – HurkanSeyhan Aug 05 '14 at 13:41

1 Answers1

1

For showing splash screen and starting the same activity,when user closes your app on home button pressed,you need to override the onPause() and onResume() ,of the activity . onPause() will be called when user will press the home button,Usesharedpreferences,to store some value referencing the current activity in SharedPreferences and when user comes back to your application onResume will be called where you can retrieve the value of the variable of sharedpreferences show up the splash screen and start the same activity again.

nobalG
  • 4,544
  • 3
  • 34
  • 72
  • thanks. is there no android default way of doing this. This seems to be a very common scenario so you mean everyone handles it this way? – Sunny Aug 05 '14 at 13:41