Just rewrite onBackPressed() in your activity and snippet and complete the calls you need.
More for callbacks / links to other snippets can be found here:
Communication with other fragments
public class FragmentA extends Fragment { public void updateMyself(String updateValue){ Log.v("update", "weeee Fragment B updated me with" + updateValue); } } public class FragmentB extends Fragment { public Interface FragmentBCallBackInterface { public void update(String updateValue); } private FragmentBCallBackInterface mCallback; @Override public void onAttach(Activity activity) { super.onAttach(activity); try { mCallback = (FragmentBCallBackInterface) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement FragmentBCallBackInterface"); }
source share