Tuesday, 7 May 2013

Android Configchanges Attributes - Manifest Description



To declare that your activity handles a configuration change, edit the appropriate <activity> element in your manifest file to include the android:configChanges attribute with a value that represents the configuration you want to handle. Possible values are listed in the documentation for the android:configChanges attribute (the most commonly used values are "orientation" to prevent restarts when the screen orientation changes and "keyboardHidden" to prevent restarts when the keyboard availability changes). You can declare multiple configuration values in the attribute by separating them with a pipe | character.



android:configChanges=["mcc", "mnc", "locale",
"touchscreen", "keyboard", "keyboardHidden",
"navigation", "screenLayout", "fontScale", "uiMode",
"orientation", "screenSize", "smallestScreenSize"]

Now, when one of these configurations change, MyActivity does not restart. Instead, the MyActivity receives a call to onConfigurationChanged(). This method is passed a Configuration object that specifies the new device configuration. By reading fields in the Configuration, you can determine the new configuration and make appropriate changes by updating the resources used in your interface. At the time this method is called, your activity's Resources object is updated to return resources based on the new configuration, so you can easily reset elements of your UI without the system restarting your activity.

Lists configuration changes that the activity will handle itself. When a configuration change occurs at runtime, the activity is shut down and restarted by default, but declaring a configuration with this attribute will prevent the activity from being restarted. Instead, the activity remains running and its onConfigurationChanged() method is called.



Value
Description
"mcc"
The IMSI mobile country code (MCC) has changed — a SIM has been detected and updated the MCC.
"mnc"
The IMSI mobile network code (MNC) has changed — a SIM has been detected and updated the MNC.
"locale"
The locale has changed — the user has selected a new language that text should be displayed in.
"touchscreen"
The touchscreen has changed. (This should never normally happen.)
"keyboard"
The keyboard type has changed — for example, the user has plugged in an external keyboard.
"keyboardHidden"
The keyboard accessibility has changed — for example, the user has revealed the hardware keyboard.
"navigation"
The navigation type (trackball/dpad) has changed. (This should never normally happen.)
"screenLayout"
The screen layout has changed — this might be caused by a different display being activated.
"fontScale"
The font scaling factor has changed — the user has selected a new global font size.
"uiMode"
The user interface mode has changed — this can be caused when the user places the device into a desk/car dock or when the night mode changes. See UiModeManager. Added in API level 8.
"orientation"
The screen orientation has changed — the user has rotated the device.
Note: If your application targets API level 13 or higher (as declared by the minSdkVersion and targetSdkVersion attributes), then you should also declare the "screenSize" configuration, because it also changes when a device switches between portrait and landscape orientations.
"screenSize"
The current available screen size has changed. This represents a change in the currently available size, relative to the current aspect ratio, so will change when the user switches between landscape and portrait. However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).
Added in API level 13.
"smallestScreenSize"
The physical screen size has changed. This represents a change in size regardless of orientation, so will only change when the actual physical screen size has changed such as switching to an external display. A change to this configuration corresponds to a change in the smallestWidth configuration. However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).
Added in API level 13.
"layoutDirection"
The layout direction has changed. For example, changing from left-to-right (LTR) to right-to-left (RTL). Added in API level 17.



For More Details :

Our Android Applications on Google Play

Thanks
NovaRadix Technology, India
Skype : novaradix
Gmail: novaradix@gmail.com


No comments:

Post a Comment