You have a few options:
- You could wrap the more complex structure in a class that implements the
Parcelable
interface, which can be stored in an extra
- You could wrap the more complex structure in a class that implements the
Serializable
interface, which can be stored in an extra
- You use static data members to pass stuff around, since they are all in the same process
- You use external storage (file, database,
SharedPreferences
)
- As the person who just posted noted, use a common component, such as a custom
Application
or a local Service
What you do not want to do is pass big stuff via extras. For example, if you are creating an application that grabs pictures off the camera, you do not want to pass those in extras -- use a static data member (icky as that sounds). Intents are designed to work cross-process, which means there is some amount of data copying that goes on, which you want to avoid when it is not necessary for big stuff.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…