One, does not need to return the value the jump
Intent intent=new Intent ();
Intent.setclass (current acitivy.this, Target activity.class);
StartActivity (Intent);
Second, a jump that needs a return value
Intent intent=new Intent ();
Intent.setclass (current acitivy.this, Target activity.class);
StartActivity (Intent);
Startactivityforresult (Intent, status value (int type));
The status value is used as a validation of the accepted target return value.
Requestcode receive the returned status value
RESULTCODE:RESULT_OK Result_canceled can assign its own value, press the return key, the system default assignment is: result_canceled
Target activity closed to return request activity
For example:
1. Request page
public class Mainactivy extends Activity {
@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.main);
Intent intent=new Intent ();
Intent.setclass (Mainactivy.this, Receivemsg.class);
Startactivityforresult (Intent, 0);
}
protected void Onactivityresult (int requestcode, int resultcode, Intent data) {
TODO auto-generated Method Stub
Super.onactivityresult (Requestcode, ResultCode, data);
if (requestcode==0) {
if (RESULTCODE==RESULT_OK) {
Toast.maketext (This, "Send SMS result_ok", Toast.length_short). Show ();
}else if (resultcode==result_canceled) {
Toast.maketext (This, "result Cancel", Toast.length_short). Show ();
}else {
Toast.maketext (This, ResultCode, Toast.length_short). Show ();
}
}else {
Toast.maketext (This, "Requsetcode not 0", Toast.length_short). Show ();
}
}
}
2. Receive the return value interface
public class Receivemsg extends activity{
protected void OnCreate (Bundle savedinstancestate) {
//TODO auto-generated Method stub
Super.oncreate (savedinstancestate);
receivemsg.this.setresult (RESULT_OK);
this.finish ();
}
}