活动A跳转到活动B,从B获取到数据.
活动A写法:
startActivityForResult(new Intent(getActivity(), MonthCalendarActivity.class), 1);
并重写onActivityResult
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == 1 && requestCode == 1) { String date = data.getStringExtra("date"); } }
活动B写法
Intent intent = getIntent(); intent.putExtra("date", date); setResult(1, intent); finish();