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

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -