Code example for Fragment

Methods: onDetach

	public static class TrackerFragment extends Fragment {
		public GoogleAnalyticsTracker tracker;
		public void onDetach() { 
		public TrackerFragment() {} 
	// simple convenience function for when a fragment wants to log a URL 
	// don't need to worry about making sure it only happens once, because Fragments manage their own state 
	// in a way that activities do not. 
	public static void track(Fragment fragment, String url) {
		if (fragment.isAdded()) {
			GoogleAnalyticsTracker tracker = start(fragment.getActivity());
			page(fragment.getActivity(), tracker, url);
Experience pair programming with AI  Get Codota for Java