Skip to content

Instantly share code, notes, and snippets.

@jiangecho
Created October 28, 2015 07:38
Show Gist options
  • Save jiangecho/1f734919c35b37b474e0 to your computer and use it in GitHub Desktop.
Save jiangecho/1f734919c35b37b474e0 to your computer and use it in GitHub Desktop.
nested fragment's onActivityResult is not called.

@Override public void startActivityForResult(final Intent _intent, final int _requestCode) { final FragmentManager fragmentManager = getActivity().getSupportFragmentManager();

final Fragment f = new Fragment() {
	@Override
	public void onAttach(Context context) {
		super.onAttach(context);
		startActivityForResult(_intent, _requestCode);
	}

	@Override
	public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
		if (_requestCode == requestCode) {
			ThisFramgnet.this.onActivityResult(requestCode, resultCode, data);
		}
		fragmentManager.beginTransaction().remove(this).commit();
	}
};
fragmentManager.beginTransaction().add(f, null).commit();

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment