android - Unable to remove fragment from transaction -
in app, need remove set of fragments transaction when os recreate app due configuration change. i'm trying following;
@override public void oncreate(bundle savedinstancestate) { if (savedinstancestate != null) { fragmentmanager fm = getsupportfragmentmanager(); list<android.support.v4.app.fragment> fragments = fm.getfragments(); (fragment fragment : fragments) { if (fragment != null) { if (!((fragment instanceof fragmenttype1) || (fragment instanceof fragmenttype2) || (fragment instanceof fragmenttype3))) { fragmenttransaction trans = fm.begintransaction(); trans.remove(fragment).commit(); } } } } }
though trans.remove(fragment).commit()
executed successfully, debugging shows these fragments still there in fragmentmanager
. can tell i'm doing wrong here.
android android-fragments
No comments:
Post a Comment