Method 1:
If you simply pass list <string> or list <integer>, you can directly use
Java code
Intent. putstringarraylistextra (name, value)
Intent. putintegerarraylistextra (name, value)
Method 2:
If list <Object> is passed, you can convert list to serializable type, and then use
Java code putextras (Key, (serializable) List)
Method passed, used for acceptance
Java code (list <yourobject>) getintent (). getserializable (key)
You can receive the list <yourobject> data.
But remember that your yourobject class must implement the serializable interface.
Method 3:
One is
Java code bundle. putserializable (Key, object );
The other is
Java code bundle. putparcelable (Key, object );
Of course, these objects have certain conditions. The former implements the serializable interface, while the latter implements the parcelable interface.
Method 4:
It is inconvenient to use intent to transmit data. We can write a global data in the application.
1. Create a subclass of your own Android. App. Application
2. Declare this class in manifest,
3. In this case, Android creates a globally available instance. You can use context. getapplicationcontext () to obtain the instance anywhere else, and then obtain the status (variable ).
Inherit Application
Java code
Class MyApp extends application {
Private string mystate;
Public String getstate (){
Return mystate;
}
Public void setstate (string s ){
Mystate = s;
}
}
For the configuration in androidmanifest. XML, you can directly add a name to the 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 I feel more commonly used to open parameters here: http://hi.baidu.com/ihsauqaxblbdmwq/item/dfc9cf9c352b0bdf1a49dfd5