I have an android application with a LOT of activities, think of something like a book where every page is a new activity. The user can make changes in each activity, for example highlight certain texts with different colored markers etc. and it's crucial that I'll remember this information as long as the application stays alive (and I don't want/need to remember any of this when it's not). As I understand the best mechanism for storing this kind of information is via onSaveInstanceState(Bundle outState)
and onCreate(Bundle)
/onRestoreInstanceState(Bundle)
rather than lets say, the Preferences mechanism. My only problem is that the user can navigate backwards to previous pages (Activities) and the only way i know of achieving this is by calling finish()
which of course kills the current activity without calling onSaveInstanceState(Bundle outState)
and even if it did call it, the next time I would launch an activity representing that page it would be an entirely new instance. So my question is: Is there a way to go back to the previous activity without calling finish()
? or, is there a better way to save this information? maybe through static variables?
Thanks!
P.S. I know I could also implement my app differently so that not every page would have its own activity but this isn't the answer I'm looking for.
Try to use startActivity() with flags such as Intent.FLAG_ACTIVITY_CLEAR_TOP. You could read the full story here: http://developer.android.com/reference/android/content/Intent.html#setFlags(int)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With