Skip to content

Instantly share code, notes, and snippets.

@DavidMont
Forked from mcelotti/android_forward_result
Created September 30, 2016 05:16
Show Gist options
  • Select an option

  • Save DavidMont/9e7984addf5964e0982e2c933ba604ab to your computer and use it in GitHub Desktop.

Select an option

Save DavidMont/9e7984addf5964e0982e2c933ba604ab to your computer and use it in GitHub Desktop.
Android FLAG_ACTIVITY_FORWARD_RESULT howto
Nav flow is: A => B => C => A with results from C
If you're using fragments please note that "onActivityResult" will be called according to where "startActivityForResult" is called (method "startActivityForResult" is available in both, activity and fragment)
ActivityA
startActivityForResult(intentB, 22);
ActivityB
intentC.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
startActivity(intentC);
finish();
ActivityC
setResult(99);
finish();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment