java - Replacing Main Fragment from its Child Fragment -
enter image description here i'm trying replace mainfragment other fragment childfragment of mainfragment . using part of code: android.support.v4.app.fragmentmanager fragmentmanager = getfragmentmanager(); fragment fragment = null; fragment = mainfragment2.class.newinstance(); fragmentmanager.begintransaction().replace(r.id.flcontent, fragment).commit(); fragmentmanager.executependingtransactions(); problem is, mainfragment get's destroyed , replacing successful, problem child of mainfragment never gets destroyed , child methods(destroy, pause, stop..) never called(i need methods). remain in memory , when getting between activities in app onresume() method of child fragment gets called. strange. i'm doing wrong here? create interface : interface mainnavigaton { void replacefragment(); } on main activity class activity exteds... implements mainnavigation...