android - Saving state of activity on orientation change using different Layouts? -
i using 2 different layouts same activity, on orientation change activity state not maintained. please suggest how that?
you can store "activity state" using onsavedinstancestate. example:
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); if(saveinstancestate != null) { if(savedinstancestate.getboolean("running") == true) { // running } else { // not running } } } @override protected void onsaveinstancestate(bundle outstate) { super.onsaveinstancestate(outstate); if(condition) { outstate.putboolean("running", true); } }
Comments
Post a Comment