Strange screen rotation behaviour in Android -


i have 2 activities in app.

the main activity displayed when device in portrait position, , when device turned landscape 'summary screen' activity (showandtellactivity) started.

this part of app seems work reliably , achieved following:

@override public void onconfigurationchanged (configuration newconfig) {     super.onconfigurationchanged(newconfig);      int orientation=newconfig.orientation;      switch(orientation) {          case configuration.orientation_landscape:              show_and_tell_intent.setclass(getapplicationcontext(),showandtellactivity.class);             show_and_tell_intent.putextra("each_pays", v_currency_symbol.concat(new decimalformat("0.00").format(v_each_to_pay)));             startactivity(show_and_tell_intent);              break;          case configuration.orientation_portrait:              break;      } } 

the summary activity contains following code finish() activity when device rotated portrait position:

@override public void onconfigurationchanged (configuration newconfig) {     super.onconfigurationchanged(newconfig);      int orientation=newconfig.orientation;      switch(orientation) {          case configuration.orientation_landscape:              break;          case configuration.orientation_portrait:              finish();             break;          case configuration.orientation_undefined:              finish();             break;      } } 

when device rotated portrait first time, however, summary activity not finish - instead summary screen displayed in portrait (which looks bad).

rotating device landscape (summary screen looks ok again) , portrait second time results in summary activity finishing expected.

from point on rotating device seems work reliably app switching between activities correctly. in other words first rotation portrait not seem trigger finish() of summary activity.

it's though when summary screen activity starts, doesn't know orientation until has changed once.

i faced similar issue. in case, onconfigurationchanged not getting called first time. me onrestoreinstancestate() worked

@override protected void onrestoreinstancestate(bundle savedinstancestate)  {     super.onrestoreinstancestate(savedinstancestate);     if (savedinstancestate != null)      {         switch(getresources().getconfiguration().orientation) {             case configuration.orientation_landscape:                 break;              case configuration.orientation_portrait:                 finish();                 break;              case configuration.orientation_undefined:                 finish();                 break;         }      } } 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -