I have one scenario to main with activities..
I have three activities A, B, C
Now I am calling C from A
A-->C
and in C I have onBackPress
Same way using startActivity for result
B-->C
So in my A and B I am using StartActitivity for result and maintaining in OnActivityForResult..
Activity A
Intent i = new Intent(this, AddNewAddress.class);
i.putExtra("addresstype", addressType);
startActivityForResult(i, 10);
And in OnActivityResult
of A
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
// check if the request code is same as what is passed here it is 2
switch (requestCode) {
case (10): {
// do this if request code is 10.
addressType=data.getStringExtra("MESSAGE");
getAddressList(userId,addressType);
mAdapter.notifyDataSetChanged();
addrListModels.clear();
}
break;
}
}
Same thing I am doing in B as well....
Now in C
@Override
public void onBackPressed() {
super.onBackPressed();
Intent intent=new Intent();
intent.putExtra("MESSAGE",addresstype);
setResult(10,intent);
finish();
}
And crash is happening
java.lang.RuntimeException: Failure delivering result ResultInfo
Remove super.onBackPressed();
in C's onBackPressed
method,please have a try.