java - Track Orientation Changes without using onConfigurationChanged() -


i have been working on assignment displays text field counting number of time orientation changed shown below.

what i'm trying accomplish app:

the problem above app's code using onconfigurationchanged(), , believe not suppose bypass activity lifecycle, cannot find way listen orientation change , increment counter.

   public void onconfigurationchanged(configuration newconfig) {     super.onconfigurationchanged(newconfig);     log.i(tag, "orientation has changed");     mcurrentindex++;     textview text= (textview) findviewbyid(r.id.mytextview);     text.settext("orientation changes: " + ochanges()); } 

is im using because if put mcurrentindex, counter, in lifecycle method onpause() called if went homescreen or that.

doing onconfigurationchanged right method. can in way, lot of work. in onsaveinstancestate, write current orientation , value of counter. in onrestoreinstancestate, read both in. if new orientation not match old orientation, increment counter after reading in.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -