其他分享
首页 > 其他分享> > android -does从活动调用完成破坏托管片段?

android -does从活动调用完成破坏托管片段?

作者:互联网

我有一个“活动A”,主持一个’片段B’.请确认如果我调用A.finish(),那么’片段B’将被销毁.片段B已经被添加到片段管理器中.我意识到一个片段是一个子活动,但我想知道我是否必须告诉片段管理器在Ondestroy中释放片段还是全部都要处理?

解决方法:

but i want to know do i have to tell the fragment manager to 
release the fragment in Ondestroy or is it all taken care of ?

默认情况下,当您在活动中调用finish时,它将自动调用附加到活动的所有片段的onDestroy方法,从而销毁它,因此无需担心在活动的onDestroy方法中销毁片段.

documentation

For example, when the activity is paused, so are all fragments in it, 
and when the activity is destroyed, so are all fragments. 

标签:android,fragment,fragmentmanager,fragment-lifecycle
来源: https://codeday.me/bug/20190528/1173031.html