Created
January 3, 2018 03:29
-
-
Save afiqiqmal/2d1ad4d5754fd70c9b80194dc3096956 to your computer and use it in GitHub Desktop.
Set On Activity Result with fragment
This file contains hidden or 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
Fragment fragment = new TaskFormFragment(); | |
fragment.setTargetFragment(this, 1000); | |
getFragmentManager() | |
.beginTransaction() | |
.replace(R.id.frame_map, fragment, "form") | |
.addToBackStack("form") | |
.commit(); | |
@Override | |
public void onActivityResult(int requestCode, int resultCode, Intent data) { | |
if (resultCode == Activity.RESULT_OK) { | |
if (requestCode == 1000) { | |
loadData(); | |
} | |
} | |
} |
This file contains hidden or 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
getTargetFragment().onActivityResult( | |
getTargetRequestCode(), | |
Activity.RESULT_OK, | |
new Intent().putExtra("refresh", true) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment