I am using support fragment,and in my fragment I have setRetainInstance(true).I read that fragment's onCreate() and onDestroy() will not be called on a configuration change if we have setRetainInstance(true) in our fragment.But still activity is recreated and fragment's onCreate() is called when I changed font style in my samsung note3.Is this a configuration change?If yes why fragment instance got initialised.If it is not a configuration change how should we handle it.Anyone please clarify.
-
I noticed you post 2 exactly same questions. Please delete the older one to avoid possible confusion among other readers and future postings. – The Original Android Jun 25 '15 at 07:20
-
1@TheOriginalAndroid deleted old question.sorry for duplicate entry. – Raji A C Jun 25 '15 at 07:29
1 Answers
I find the question interesting since it relates to Configuration Change. As you know normally all configuration change will trigger onCreate() and onDestroy(). And that makes sense and your code normally does not even care unless you don't adhere to the Fragment lifecycle. For the sake of other readers, setRetainInstance(true) should not trigger onCreate() and onDestroy(), as you said.
Font style change is definitely a configuration change. And Samsung may reload your app activity and they can do that, and they make their own Android Home screen. I found one related SO webpage @ ...configChanges value for Font Style change in Samsung Device. Read the answer to that post.
One suggestion I have is to place the code in onCreate() such that you don't care about this issue. Otherwise you may have to override a method for font changes or possibly other changes too.

- 1
- 1

- 6,147
- 3
- 26
- 31
-
binding views in fragment can not be done in oncreate().Can you please elaborate ,override a method for font changes?If it is possible to track these kind of configuration changes then it is better to exit the application,but still we don't have a generic way to get call back for "these changes" in our application. – Raji A C Aug 11 '15 at 08:03