A跳转到B,在B中要返回到A,并传递数据给A
在A中跳转代码如下
Intent intent = new Intent();
intent.setClass(A.this, B.class);
startActivityForResult(intent, 0);
并在A中重写
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
switch (resultCode) {
case RESULT_OK:
txtBarList = data.getStringArrayListExtra("txtBarList");
break;
default:
break;
}
super.onActivityResult(requestCode, resultCode, data);
}
在B中,返回的按钮上写
Intent intent = getIntent();
intent.putExtra("txtBarList", txtBarList);
AddGroup.this.setResult(RESULT_OK, intent);
AddGroup.this.finish();
A可以在
onActivityResult
中获取B传递来的数据