前一个activity跳转到后一个activity设置code:

Intent intent=new Intent(MainActivity.this,ActivityTwo.class);
startActivityForResult(intent,0x123);

重写前一个activity的onActivityResult方法:

@Override
protected void onActivityResult(int requestCode,int resultCode,Intent data){
super.onActivityResult(requestCode,resultCode,data); if(requestCode==0x123 && resultCode==0x123){
Bundle bundle=data.getExtras();
String test=bundle.getString("test");
Log.i("HelloWorld",test);
}
}

后一个activity跳转到前一个activity设置code:

Intent intent=getIntent();
Bundle bundle=new Bundle();
bundle.putString("test","zqx");
intent.putExtras(bundle);
setResult(0x123,intent);
finish();
05-11 13:29