What is the difference between
Intent i = new Intent(getActivity(), HomeworkPagerActivity.class);
i.putExtra(HomeworkFragment.EXTRA_HOMEWORK_ID, c.getId());
startActivity(i);
and:
HomeworkFragment newFragment = new HomeworkFragment();
Bundle args = new Bundle();
args.putInt(HomeworkFragment.ARG_POSITION, position);
newFragment.setArguments(args);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_container, newFragment);
transaction.addToBackStack(null);
transaction.commit();
I'm using a Fragment to launch another Fragment.
However, which one should be used and why?
Additionally, I need to transmit data from the child Fragment (HomeworkFragment) back to the Fragment that launched it in the first place. Which setup allows data (like an id number) to be transmitted easily?