Configuration changed (orientation change) and destroying Activities - is this the way it's supposed to work?

前端 未结 4 661
轻奢々
轻奢々 2020-12-31 04:00

I read up on how Android handles \"configuration changes\" - by destroying the active Activity.

I really want to know from Android Team why this is. I would apprecia

4条回答
  •  醉梦人生
    2020-12-31 04:45

    @Alex's approach above pointed me to a really, really useful solution when using fragments:

    Fragments usually get recreated on configuration change. If you don't wish this to happen, use

    setRetainInstance(true); in the Fragment's constructor(s)

    This will cause fragments to be retained during configuration change.

    http://developer.android.com/reference/android/app/Fragment.html#setRetainInstance(boolean)

提交回复
热议问题