android - FragmentManager replace fragments without calling onPause() onDestroy() for the old fragment -


in application, have left menu controls fragment transactions in 1 fragmentview in mainactivity. above fragmentview have new pulltorefresh component used in new gmail being refreshed in 1 fragment.

enter image description here

i want stop refreshing of if have replaced fragment one.

getsupportfragmentmanager().begintransaction()             .replace(r.id.fragment_container, new pulltorefreshfragment())             .commit(); 

i expected fragmentmanager stick traditional fragmentlifecycle then, decided stop pulltorefresh component in onpause, ondestroy, onstop or ondetach() methods. unfortunately, method never been called on replacing fragment. been replace if have selected same fragment left menu.

@override public void ondetach() {     if(mpulltorefreshlayout.isrefreshing()){         mpulltorefreshlayout.setrefreshcomplete();     }     super.ondetach(); } 

that means that, fragmentmanager caching fragments , not destroy them unless if trying replace fragment fragment same type.

my question is, fragment lifecycle in case of replacing or adding new fragment on 1 using fragmentmanager?

where should stop pulltorerfesh component, if want stop when replacing fragment one?


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -