You can use the startActivityForResult()
method that allows an to call an ActivityB and receive a return from it.
To do this, in your ActivityA call ActivityB using the startActivityForResult()
method. An example:
Intent i = new Intent(this, ActivityB.class);
/*
Crie seu Bundle e coloque dados
*/
startActivityForResult(i, 1); // O '1' é um id para a operação
In your ActivityB do the normal procedure to get ActivityA data and when you return them, type the following code in ActivityB :
Intent intentRetorno = new Intent();
intentRetorno.putExtra("resultado", dadoDeRetorno);
setResult(RESULT_OK, intentRetorno);
finish();
Then, make your ActivityA implement the onActivityResult()
method.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1) {
if(resultCode == RESULT_OK){
String result = data.getStringExtra("resultado");
}
}
}