Android : Get previous fragment name to do nothing in onCreate -


i have detected bug in app today : when user clic on item in listview, launch new fragment details item. when user in fragment, if change orientation of device, oncreate method of first class (which fetch listview) called, , app crashed.

i know if it's possible name of previous fragment, in order add test following in oncreate method :

if (!fragmentname.equals("common")){         log.d("info", "do nothing in case, because user in detail fragment before !"), } else {         super.oncreate(savedinstancestate);          refreshlist(true); } 

i don't think possible name of previous fragment creating new instance of fragment object.

if right in trying need somehow store object displaying data when fragment recreated can retrieve required object. 1 way keep id or unique property of object in sharedpreferences , reacquire data when reloads singleton somewhere.

basically may need change way retrieve data or pass original opening fragment can retrieve again if second fragment destroyed.


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -