Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I remove all fragment when activity destroy

Do you know how can I clear all fragments in an activity, in layout and in backstack.

I know that we can clear backstack by using:

FragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);

But what about in layout which I have dynamically added to layout.

like image 280
kdtphdav Avatar asked Sep 02 '12 17:09

kdtphdav


2 Answers

How can I remove all fragment when activity destroy

All fragments are automatically destroyed when the activity holding them is destroyed.

like image 68
CommonsWare Avatar answered Oct 10 '22 09:10

CommonsWare


You do not need to bother. Once activity is destroyed all fragments will be destroyed too

like image 35
Marcin Orlowski Avatar answered Oct 10 '22 08:10

Marcin Orlowski