android - Activity retain instance of Fragment on onSaveInstance -
i'm writing application using onsaveinstance(..) retain values on device config change(say device font, local).
here application activity using multiple fragment display. after chnage in config change when coming back app oncreate(..) execute , app checked if bundle object null. till state app didn't set fragment child but still last set fragment (before change in config) child started execute it's life cycle method.
how can prevent it, 1 way check same bundle object fragment child, same activity , return. there other way remove child activity on device-config change!
activity reference code handle re-calling:
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.reading_activity); if(savedinstancestate == null) { init(savedinstancestate); } else { // don't } } here init(..) responsible set fragment child.
Comments
Post a Comment