I have an Android Activity with a RelativeLayout and I have implemented the following method to prevent the activity from being recreated on change of Orientation:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
I am obviously not doing anything in this method, but it worked perfect when using a LinearLayout. Now however, using RelativeLayout, my layout is all messed up when changing to landscape orientation.
What is the most efficient way to have the screen redraw correctly without having the activity restarted again with a call to onCreate?
You have two ways:
You have chosen the second way. In this case you have to reassign every resource by hand and this approach is not recommended.
IMHO the best way is the first by implementing the method: onRetainNonConfigurationInstance();
Here a complete example on howto use.
Note: the onCreate will be called again but you can adjust your code to prevent long runnning task to be called again during a configuration change