From b1444578d47f9db952815ec6845a1ea03ab2424e Mon Sep 17 00:00:00 2001 From: Felipe Leme Date: Tue, 3 Nov 2015 17:39:07 -0800 Subject: [PATCH] Clarified usage of onDetach() and onCreate() when setRetainInstance() is set to true. BUG: 25455734 Change-Id: I667629b76dcc39b0d2415cd368629720a77ed337 --- core/java/android/app/Fragment.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java index e038a72ffa59e..a73ad09d5f558 100644 --- a/core/java/android/app/Fragment.java +++ b/core/java/android/app/Fragment.java @@ -1410,7 +1410,8 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene /** * Called to do initial creation of a fragment. This is called after * {@link #onAttach(Activity)} and before - * {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}. + * {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}, but is not called if the fragment + * instance is retained across Activity re-creation (see {@link #setRetainInstance(boolean)}). * *

Note that this can be called while the fragment's activity is * still in the process of being created. As such, you can not rely @@ -1649,8 +1650,10 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene } /** - * Called when the fragment is no longer attached to its activity. This - * is called after {@link #onDestroy()}. + * Called when the fragment is no longer attached to its activity. This is called after + * {@link #onDestroy()}, except in the cases where the fragment instance is retained across + * Activity re-creation (see {@link #setRetainInstance(boolean)}), in which case it is called + * after {@link #onStop()}. */ public void onDetach() { mCalled = true;