The activity hosting this fragment has its onActivityResult
called when the camera activity returns.
My fragment starts an activity for a result with th
Option 1:
If you're calling startActivityForResult()
from the fragment then you should call startActivityForResult()
, not getActivity().startActivityForResult()
, as it will result in fragment 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 two options do not work, then refer to option 3 as it will definitely work.
Option 3:
An explicit call from fragment to the onActivityResult function is as follows.
In the parent Activity class, override the onActivityResult() method and even override the same in the Fragment class and call as the following code.
In the 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 the child class:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// In fragment class callback
}