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
Java code
Class MyApp extends Application {
Private String MyState;
Public String getState () {
return mystate;
}
public void SetState (String s) {
MyState = s;
}
}
Regarding the configuration in the Androidmanifest.xml, it is possible to add a name directly to application, as shown below:
Java code <application android:name= ". MyApp "android:icon=" @drawable/icon "android:label=" @string/app_name ">
Use
Java code
Class Blah extends Activity {
@Override
public void OnCreate (Bundle b) {
...
MyApp appState = (MyApp) getapplicationcontext ());
String state = Appstate.getstate ();
...
}
}
This is reproduced, but feel that they are more commonly used to facilitate participation in the open here: http://hi.baidu.com/ihsauqaxblbdmwq/item/dfc9cf9c352b0bdf1a49dfd5
Android Intent passing list or object