I have a MainActivity
that allows me to open two Fragments
. The Fragment_1
class has a Button
that in its Listener
opens a second activity through the following call:
Intent intent = new Intent(getActivity(), SegundaActivity.class);
getActivity().startActivityForResult(intent, 1);
My problem is that in class Fragment_1
I can not catch the Intent
response through the onActivityResult()
method:
if (resultCode == Activity.RESULT_OK && requestCode == 1) {
String resposta = data.getStringExtra("resposta");}
In class SegundaActivity
, the response is sent as follows:
Intent devolve = new Intent();
devolve.putExtra("resposta", "Resposta");
setResult(Activity.RESULT_OK, devolve);
finish();