Configchanges attribute usage in Activity
By setting this attribute, activity can capture device status changes. The following content can be recognized:
Config_font_scale
Config_mcc
Config_mnc
Config_locale
Config_touchscreen
Config_keyboard
Config_navigation
Config_orientation
Setting Method: Separate the following fields with the "|" symbol, for example, "locale | navigation | Orientation
"
Value |
Description |
"MCC" |
The imsi mobile country code (MCC) has changed-that is, a sim hasbeen detected and updated the MCC. the mobile country number consists of three digits. Each country has its own independent MCC, which can identify the country to which the mobile phone user belongs. |
"MNC" |
The imsi mobile network code (MNC) has changed-that is, a sim hasbeen detected and updated the MNC. Mobile Network number, which is used to differentiate mobile phone users in a country or region. |
"Locale" |
The locale has changed-for example, the user has selected a new language that text shoshould be displayed in. The region of the user changes. |
"Touchscreen" |
The touchscreen has changed. (This shoshould never normally happen .) |
"Keyboard" |
The keyboard type has changed-for example, the user has plugged in an external keyboard. The keyboard mode changes, for example, the user accesses the External keyboard input. |
"Keyboardhidden" |
The keyboard accessibility has changed-for example, the user has slid the keyboard out to expose it. the user opens the hardware keyboard of the mobile phone. |
"Navigation" |
The navigation type has changed. (This shoshould never normally happen .) |
"Orientation" |
The screen orientation has changed-that is, the user has rotated the device. device rotation, horizontal display and vertical display mode switch. |
"Fontscale" |
The font scaling factor has changed-that is, the user has selected a new global font size. The Global font size scaling changes |
An example is provided to describe how to use this property: First, you need to modify the manifest of the project:
? View code XML
<ManifestXmlns: Android = "http://schemas.android.com/apk/res/android" Package = "com. androidres. configchangedtesting" Android: versioncode = "1" Android: versionname = "1.0.0"> <ApplicationAndroid: icon = "@ drawable/icon" Android: Label = "@ string/app_name"> <ActivityAndroid: Name = ". configchangedtesting" Android: Label = "@ string/app_name" Android: configchanges = "keyboardhidden | orientation"> <Intent-Filter> <ActionAndroid: Name = "android. Intent. Action. Main"/> <CategoryAndroid: Name = "android. Intent. Category. launcher"/> </Intent-Filter> </Activity> </Application> </Manifest> |
The Android: configchanges attribute is added to the activity to notify the program to call the onconfigurationchanged () function when the specified attribute (configuration changes) changes.