1

我在我的应用程序中遇到内存问题,它使用 TabHost 和 TabGroupActivity 作为 TabContent。

我注意到有时 Activity 的生命周期很奇怪。

我启动应用程序,加载了 tab1,然后单击 tab2 (Tab1->Tab2 )

Tab1Group.onPause called
Tab1.onPause called

Tab2Group.onCreate called
Tab2.onCreate called

然后我返回 Tab1 (Tab2->Tab1)

Tab2Group.onPause called 
Tab1Group.onDestroy called
Tab1.onDestroy called
Tab1.onCreate called

好吧,如果我回来时 tab1 被破坏了,最好直接破坏它而不是调用onPause,这样 VM 可以释放更多内存。

你怎么看 ?

4

1 回答 1

0

手动清除所有意图并清空所有对象

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addCategory(Intent.CATEGORY_HOME); 
startActivity(intent);
于 2012-07-30T12:53:22.173 回答