onActivityResult() not called

I solved my problem by removing android:noHistory="true" from AndroidManifest.xml.


Option 1 :

If you're calling startActivityForResult() from the Fragment then you should call startActivityForResult() and not getActivity().startActivityForResult(), as it will result in Fragment's onActivityResult().

If you're not sure where you're calling on startActivityForResult() and how you will be calling methods.

Option 2:

Since Activity gets the result of onActivityResult(), you will need to override the Activity's onActivityResult() and call super.onActivityResult() to propagate to the respective Fragment for unhandled results codes or for all.

If above 2 options do not work, then refer option 3 as it will definitely work.

Option 3 :

Explicit call from Fragment to onActivityResult() function as follows

In parent Activity class, override the onActivityResult() and even override the same in Fragment class and call as the following code.

In parent class:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.dualPane);
    fragment.onActivityResult(requestCode, resultCode, data);
}

In child class:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   //in fragment class callback
}