我画了这个问题:
有人知道解决方案吗?
答案 0 :(得分:1)
使用startActivityForResult从ActivityB
开始ActivityA
。
int REQUEST_CODE = 99; // random number here
startActivityForResult(activityAIntent, REQUEST_CODE);
1)在ActivityB
电话:
setResult(RESULT_OK);
finish();
2)来自ActivityA
的{{1}}抓住RESULT_OK
:
ActivityB
其他解决方案如果您在开始@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Check which request we're responding to
if (requestCode == REQUEST_CODE) {
// Make sure the request was successful
if (resultCode == RESULT_OK) {
// finish ActivityA and navigate back to FragmentA
setResult(RESULT_OK);
finish();
}
}
}
后不需要ActivityA
,请在ActivityB
中致电finish()
ActivityA
。完成后,您只需拨打ActivityB
中的finish()
,用户就会按预期导航回ActivityB
。