Code example for FragmentTransaction

Methods: addToBackStack, commit, replace

		// Create new fragment and transaction 
		FragmentTransaction transaction = fm.beginTransaction();
		// Replace whatever is in the fragment_container view with this fragment, 
		// and add the transaction to the back stack 
		transaction.replace(containterViewId, frag, fragTag);
		// Commit the transaction 
	public static int requestFragment(Fragment frag, int containerViewId, 
			String fragTag, FragmentManager fm)
		LogEntryEditActivity logEntryEdit = (LogEntryEditActivity) fm.findFragmentByTag(Constants.TAG_LOG_ENTRY_EDIT);
		// if the backstack contains 1 or more entries and one of them isn't a logEntryEditFragment (another activity is being performed) 
		// OR if the backstack contains 2 or more entried and one of them is a logEntryEditFragment (a fragment deeper then the legEntryEdit is open) 
		if ((fm.getBackStackEntryCount() >= 1 && logEntryEdit == null) || 
			(fm.getBackStackEntryCount() >= 2 && logEntryEdit != null ))