Handling activity rotating in Android?

While it is quicker since the activity doesn't get restarted on an orientation change, it isn't typically recommended, if I recall correctly. Another way to handle orientation changes is instead of overriding onConfigurationChanged() overriding onCreate() onStart() or onResume() such that.

While it is quicker since the activity doesn't get restarted on an orientation change, it isn't typically recommended, if I recall correctly. Another way to handle orientation changes is instead of overriding onConfigurationChanged(), overriding onCreate(), onStart() or onResume() such that @Override public void onStart() { super.onStart(); int orientation = getWindowManager(). GetDefaultDisplay().getOrientation(); if(orientation == Configuration.

ORIENTATION_PORTRAIT) { Log. I(TAG, "Orientation is portrait"); // show whatever alerts here } } and then specifying two layouts - one for portrait, one for landscape. The portrait version of the layout would remain at res/layout/whatever.

Xml, and the landscape version would live in res/layout-land/whatever.xml. The AndroidGuys had written a bunch of good articles on this topic, see http://androidguys.com/?s=rotational+forces&x=9&y=9.

If I will use onCreate() or something like that the activity will be recreated and its data will be lost. – darja Sep 26 '10 at 4:32.

I'm pretty sure you would want to use onCreate rather than onStart. The only difference appears to be that onStart will get called when the application comes to the foreground. That wouldn't be a case where you'd want to make the user wait for you to re-initialize the UI.

Otherwise, just change your setContentView call based on that if condition.

– darja Sep 26 '10 at 14:11 I believe you'll end up building your UI twice in that case. Both onConfigurationChange and onCreate will get called when the screen rotates. You already have to setup the UI in onCreate for all other create situations.

– JOTN Sep 26 '10 at 18:05 I have noticed that if onConfigurationChanged is handled, activity doesn't recreate, onDestroy and onCreate are not called – darja Sep 26 '100 at 3:29.

Android starts a new instance of your activity when changing orientation so using onCreate is the ideal method. You will have to save/restore your activity's data obviously in order to pick up where you left off - but you should be doing this anyway since any number of events can unfocus/kill your application.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions