1. Message-based communication mechanism Intent---bundle, extra
Data types are limited, such as encountering non-serializable data bitmap,inputstream, or linkedlist linked lists, and so on.
2 static data, public static member variable;
3. External storage-based transmissions , File/preference/sqlite
If you want content Provider for third-party apps
4. IPC-Based communication mechanisms
The transfer between context and service, such as communication between activity and service, defines the Aidl interface file.
5. Based on application Context
This method can be used for data types such as non-serializable data bitmap,inputstream, or linkedlist linked lists, and so on.
There is currently a project that needs to use the data transfer of activity, initializing a arraylist
Java implementations:
1 Public classContactappextendsApplication {2 3 Privatearraylist4 NewArraylist();5 6 Public voidSetcontactitem (arraylistItem) {7 This. Contactmap =item;8 }9 Ten PublicArraylistGetcontactitem () { One returnContactmap; A } -}
To configure in Androidmanifest.xml:
1 <application2 android:name= ". Model. Contactapp "3 android:icon=" @drawable/icon "4 android:label=" @string/app_name " >5 ... 6 </application>
To access in other activity:
Setting Data:
1 Contactapp app = (Contactapp) getapplication (); 2 App.setcontactitem (ContactItem);
Get Data:
1 Contactapp app = (Contactapp) getapplication (); 2 app.getcontactitem ();