12

I have a Fragment that calls another Activity using:

ProductEditionMaintenanceActivity.class);
Bundle extras = new Bundle();
extras.putString("productCode", productCode);
extras.putInt("productEditionID", 0);
intent.putExtras(extras);
getActivity().startActivityForResult(intent, 1);

and return from the activity:

Intent resultIntent = new Intent();
setResult(Activity.RESULT_OK, resultIntent);
finish();

I tried to use the following in the Fragment

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
    //Do something
}

However, I am guessing the intent created passed the reference of the parent Activity of the Fragment therefore onActivityResult on the Fragment does not get called. If that is the case, what do I need to do so the fragment get the result from the callee Activity?

user2804013
  • 121
  • 1
  • 1
  • 4

1 Answers1

16

The fragments onActivityResult will get called AFTER the host activities onActivityResult as long as super.onActivityResult is called from the host activity. See https://stackoverflow.com/a/6147919/552902 for more detail

Community
  • 1
  • 1
JRomero
  • 4,878
  • 1
  • 27
  • 49