我们使用的是片段,我们也不需要他们活动时重新自动恢复。
但是Android每次当活动:在OnCreate(束savedInstanceState)
时间 - > super.onCreate(savedInstanceState)
被调用,恢复片段即使我们使用setRetainInstance(假)的那些片段。
We are using Fragments and we don't need them to be automatically recovered when the Activity is recreated.
But Android every time when Activity::onCreate(Bundle savedInstanceState)
-> super.onCreate(savedInstanceState)
is called, restores Fragments even if we use setRetainInstance(false) for those Fragments.
此外,在那些片段
Fragment.performCreateView()
被直接调用,无需通过片段:: onAttach()
等。此外,某些字段都在里面恢复空片段
...
Moreover, in those Fragments
Fragment.performCreateView()
is called directly without going through Fragment::onAttach()
and so on. Plus, some of the fields are null inside restored Fragment
...
有谁知道如何prevent的Android从恢复片段?
Does anybody know how to prevent Android from restoring fragments?
P.S。我们知道,在案件重新创建活动为配置的变化,它可以通过增加表现出一种进行ndroid:configChanges =定位|但是,我们重新创建活动的屏幕布置
|屏幕尺寸。案件的自动记忆清洗?
P.S. We know that in case of recreating Activity for config changes it could be done by adding to manifest android:configChanges="orientation|screenSize|screenLayout
. But what about recreating activity in case of automatic memory cleaning?
我们完成了加入到活动:
We finished by adding to activity:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(null);
}
据燮presses任何保存在创建/重新创建活动的周期数据,避免了碎片自动重新生成。
It suppresses any saved data on create/recreate cycle of an Activity and avoids fragments auto re-creation.