It depends on the behavior you want. Remember that Android multi-tasks. At any time, the user can go away and do something else, then return to your app later. In between, your process can be killed.
Thus if you stuff some objects into a static variable, you have to be able to handle that variable being null when your activity is started. If you stick that state into the intent, then the system will take care of saving this data and loading it again when necessary. So, it's convenient to put things here which control, for instance, what the user will see. Some things can't be serialized like that, for instance a thread. Then you have to handle reconstructing them when necessary yourself. A cache of bitmaps makes sense to stick in a static field, as long as you can rebuild it when it goes missing. User-provided data doesn't make any sense to put in a static field. You need to save that to a database or a file. Imagine you are writing a notes app. The user has 10 slots and each slot can contain some text. When the user presses slot 3, they can edit that slots text. In this case, you would store: - the text of each note in a database - the note that the user pressed in the intents extras - you can keep around a cache of the loaded notes in an ArrayList of SoftReferences, stuffed in a static field if you want It wouldn't make sense to keep the slot the user is editing in a static field, because then when your "Edit Note" activity is restarted after the process is killed it'll be zero. Put that data in the Intent instead. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

