I searched all over and there are similar posts about it, but can't find a solution!
My situation is I have an Activity A that holds a fragment
, and from that fragment
I want to start a new Activity
B that should return some values to the fragment
.
On the fragment
startActivityForResult(mapIntent, ConstantsUtils.TOMAP_REQUEST_CODE);
On the Activity
B, to return the data
Intent returnIntent = new Intent();
returnIntent.putExtra(SerializationConstants.isSearchSaved, mAbItemsShown.ordinal());
setResult (ConstantsUtils.SUCCESS_RETURN_CODE, returnIntent);
finish();
On the fragment
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
switch (requestCode) {
case ConstantsUtils.TOMAP_REQUEST_CODE:
if (resultCode == ConstantsUtils.SUCCESS_RETURN_CODE) {
//do some stuff
}
}
}
onActivityResult
from the fragment
is successfully called, with the right requestCode
but resultCode
is always 0 and intent is always null
.
I have no other onActivityResult
implementation under Activity
A.
In fact, I also try starting the activity
from the fragment
with
getActivity().startActivityForResult(mapIntent, ConstantsUtils.TOMAP_REQUEST_CODE);
and implementing onActivityResult
on Activity
A but it happens the same, right requestCode
but wrong resultCode
and intent
.
I'm using Sherlock Action Bar
so my fragment
is a SherlockListFragment
so I'm using the support library (r18)
.
Can you help me? Thanks