Demand
Oneactivity the value Name=hzs to twoactivity, then twoactivity to Oneactivity sex=y
First step: oneactivity to Twoactivity value Name=hzs
Set in Oneactivity
Intent Intent = new Intent (oneactivity.this,twoactivity.class); Intent.putextra ("name", "Hzs");
|
Value in Twoactivity
Intent getintent = Getintent (); String name = Getintent.getstringextra ("name"); |
Step two: Twoactivity to oneactivity value sex=y
Set in Twoactivity
Intent Intent = new Intent (); Intent.putextra ("Sex", "Y"); Setresult (1, intent); The ResultCode is used to distinguish the return code from where it is returned. Finish (); |
Value in Oneactivity
|
@Override
protected void Onactivityresult (int requestcode, int resultcode, Intent data) {
Switch (requestcode) {
Case 2000:
if (resultcode==1) {
String sex = Data.getstringextra ("Sex");
}
Break
Default
}
Super.onactivityresult (Requestcode, ResultCode, data);
}
|
Android Pass Value