Method One:
If you simply pass list<string> or list<integer>, you can use it directly.
Java code
Intent.putstringarraylistextra (name, value)
Intent.putintegerarraylistextra (name, value)
Method Two:
If you are passing list<object>, you can convert the list to serializable type and then through
Java code Putextras (key, (Serializable) list)
method passed past, accepted with
Java code (list< yourobject>) getintent (). getserializable (key)
to receive list<yourobject> data
But remember that your yourobject class must implement Serializable interface
Method Three:
one is
Java code Bundle.putserializable (key,object);
another is
Java code bundle.putparcelable (Key, object);
Of course, these objects have certain conditions, the former is the implementation of the serializable interface, and the latter is the implementation of the Parcelable interface
Method four:
used intent to feel inconvenient we can write a global data in application;
1. Create a subclass of your own android.app.Application
2, declare this class in manifest,
3. This is where Android builds a globally available instance that you can use Context.getapplicationcontext anywhere else () method to obtain the state (variable) of the instance.
Inherits application
class extends Application { private String mystate; Public String getState () { return mystate; } Public void setState (String s) { = s; } }
Regarding the configuration in the Androidmanifest.xml, it is possible to add a name directly to application, as shown below:
<android:name= ". MyApp " android:icon=" @drawable/icon " android:label=" @string/app_ Name ">
Use
class extends Activity { @Override publicvoid onCreate (Bundle b) {... = (MyApp) Getapplicationcontext ()); = appstate.getstate (); ... } }
This article transferred from: HTTP://HI.BAIDU.COM/IHSAUQAXBLBDMWQ/ITEM/DFC9CF9C352B0BDF1A49DFD5