用, 从你Activity_B
的:startActivityForResult()
Activity_A
//Starting a new Intent
Intent nextScreen = new Intent(getApplicationContext(), Activity_B.class);
// starting new activity
startActivityForResult(nextScreen,1000);
完成工作后Activity_B
,调用setResult()
设置数据,然后finish()
像这样
//Starting the previous Intent
Intent previousScreen = new Intent(getApplicationContext(), Activity_A.class);
//Sending the data to Activity_A
previousScreen.putExtra("Bla"," Blabla");
setResult(1000, previousScreen);
finish();
这将使您回到以前的Activity_A
.
在Activity_A
,覆盖onActivityResult()
。
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
String bla = data.getStringExtra("Bla");
}
在这里找到