Created
October 4, 2013 01:42
-
-
Save daichan4649/6819780 to your computer and use it in GitHub Desktop.
startActivityForResult (FragmentA <-> FragmentB)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// FragmentA (in Activity A) | |
private void showActivityB(int requestCode) { | |
Intent intent = new Intent(getActivity(), ActivityB.class); | |
startActivityForResult(intent, requestCode); | |
} | |
@Override | |
public void onActivityResult(int requestCode, int resultCode, Intent data) { | |
if (resultCode != Activity.RESULT_OK) { | |
return; | |
} | |
String val = data.getStringExtra("key1"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// FragmentB (in ActivityB) | |
private void close() { | |
Intent intent = new Intent(); | |
intent.putExtra("key1", "val1"); | |
getActivity().setResult(Activity.RESULT_OK, intent); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment