Handling activity rotating in Android -


I need to apply various layouts for the pictures and landscape orientation of my activity. Besides, I need to show caution If the orientation is the picture.

I've specified Android: configChanges = "orientation-keyboardHidden" in AndroidManifest. The way I changed it as an override configuration:

  Override public null at @configuration (changing the configuration to newConfig) {Log D. ("Tag", "config changed"); Super.onConfigurationChanged (newConfig); Int Orientation = newConfig.orientation; If (Orientation == Configuration.ORINTNGT), Log D. ("Tag", "portrait"); Otherwise if (orientation == configuration.ORRIENTATION_LANDSCAPE) logs D ("tag", "landscape"); Other logs W ("tag", "other:" + orientation); ....}  

From landscape to portrait logs look like:

  config changed portrait  

But when it changes from portrait to landscape, it looks

  changed configurable portrait landscape landscape  

Why the configuration has been changed, which two Is called the bar? How can I avoid it?

Here is the answer to another question:

In short, the configuration changes It's hard to do the right thing. It is best to implement that your application is called before the prevention and restart due to a configuration change. Use this method to save whatever you want ('this' is a good option) and then tear the system to your app.

When your app restarts with the new configuration, then use it to regain the state simply save, and use it to keep your application without bundles and share preferences without having anyone To do.


Comments