Class Configuration
- java.lang.Object
-
- android.content.res.Configuration
-
- All Implemented Interfaces:
Parcelable,Comparable<Configuration>
public final class Configuration extends Object implements Parcelable, Comparable<Configuration>
This class describes all device configuration information that can impact the resources the application retrieves. This includes both user-specified configuration options (locale and scaling) as well as device configurations (such as input modes, screen size and screen orientation).You can acquire this object from
Resources, usingResources.getConfiguration(). Thus, from an activity, you can get it by chaining the request withandroid.app.Activity#getResources:Configuration config = getResources().getConfiguration();
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface android.os.Parcelable
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
-
-
Field Summary
Fields Modifier and Type Field Description intcompatScreenHeightDpintcompatScreenWidthDpintcompatSmallestScreenWidthDpstatic Parcelable.Creator<Configuration>CREATORstatic intDENSITY_DPI_ANYValue fordensityDpifor resources that scale to any density (vector drawables).static intDENSITY_DPI_NONEValue fordensityDpifor resources that are not meant to be scaled.static intDENSITY_DPI_UNDEFINEDDefault value fordensityDpiindicating that no width has been specified.intdensityDpiThe target screen density being rendered to, corresponding to density resource qualifier.static ConfigurationEMPTYfloatfontScaleCurrent user preference for the scaling factor for fonts, relative to the base density scaling.inthardKeyboardHiddenA flag indicating whether the hard keyboard has been hidden.static intHARDKEYBOARDHIDDEN_NOConstant forhardKeyboardHidden, value corresponding to the physical keyboard being exposed.static intHARDKEYBOARDHIDDEN_UNDEFINEDConstant forhardKeyboardHidden: a value indicating that no value has been set.static intHARDKEYBOARDHIDDEN_YESConstant forhardKeyboardHidden, value corresponding to the physical keyboard being hidden.intkeyboardThe kind of keyboard attached to the device.static intKEYBOARD_12KEYstatic intKEYBOARD_NOKEYSstatic intKEYBOARD_QWERTYstatic intKEYBOARD_UNDEFINEDConstant forkeyboard: a value indicating that no value has been set.intkeyboardHiddenA flag indicating whether any keyboard is available.static intKEYBOARDHIDDEN_NOConstant forkeyboardHidden, value corresponding to the keysexposed resource qualifier.static intKEYBOARDHIDDEN_SOFTConstant matching actual resource implementation.static intKEYBOARDHIDDEN_UNDEFINEDConstant forkeyboardHidden: a value indicating that no value has been set.static intKEYBOARDHIDDEN_YESConstant forkeyboardHidden, value corresponding to the keyshidden resource qualifier.LocalelocaleCurrent user preference for the locale, corresponding to locale resource qualifier.intmccIMSI MCC (Mobile Country Code), corresponding to mcc resource qualifier. 0 if undefined.intmncIMSI MNC (Mobile Network Code), corresponding to mnc resource qualifier. 0 if undefined.static intMNC_ZEROConstant used to to represent MNC (Mobile Network Code) zero. 0 cannot be used, since it is used to represent an undefined MNC.static intNATIVE_CONFIG_DENSITYstatic intNATIVE_CONFIG_KEYBOARDstatic intNATIVE_CONFIG_KEYBOARD_HIDDENstatic intNATIVE_CONFIG_LAYOUTDIRstatic intNATIVE_CONFIG_LOCALEstatic intNATIVE_CONFIG_MCCstatic intNATIVE_CONFIG_MNCstatic intNATIVE_CONFIG_NAVIGATIONstatic intNATIVE_CONFIG_ORIENTATIONstatic intNATIVE_CONFIG_SCREEN_LAYOUTstatic intNATIVE_CONFIG_SCREEN_SIZEstatic intNATIVE_CONFIG_SMALLEST_SCREEN_SIZEstatic intNATIVE_CONFIG_TOUCHSCREENstatic intNATIVE_CONFIG_UI_MODEstatic intNATIVE_CONFIG_VERSIONintnavigationThe kind of navigation method available on the device.static intNAVIGATION_DPADConstant fornavigation, value corresponding to the dpad resource qualifier.static intNAVIGATION_NONAVConstant fornavigation, value corresponding to the nonav resource qualifier.static intNAVIGATION_TRACKBALLConstant fornavigation, value corresponding to the trackball resource qualifier.static intNAVIGATION_UNDEFINEDConstant fornavigation: a value indicating that no value has been set.static intNAVIGATION_WHEELConstant fornavigation, value corresponding to the wheel resource qualifier.intnavigationHiddenA flag indicating whether any 5-way or DPAD navigation available.static intNAVIGATIONHIDDEN_NOConstant fornavigationHidden, value corresponding to the navexposed resource qualifier.static intNAVIGATIONHIDDEN_UNDEFINEDConstant fornavigationHidden: a value indicating that no value has been set.static intNAVIGATIONHIDDEN_YESConstant fornavigationHidden, value corresponding to the navhidden resource qualifier.intorientationOverall orientation of the screen.static intORIENTATION_LANDSCAPEConstant fororientation, value corresponding to the land resource qualifier.static intORIENTATION_PORTRAITConstant fororientation, value corresponding to the port resource qualifier.static intORIENTATION_SQUAREDeprecated.Not currently supported or used.static intORIENTATION_UNDEFINEDConstant fororientation: a value indicating that no value has been set.static intSCREEN_HEIGHT_DP_UNDEFINEDDefault value forscreenHeightDpindicating that no width has been specified.static intSCREEN_WIDTH_DP_UNDEFINEDDefault value forscreenWidthDpindicating that no width has been specified.intscreenHeightDpThe current height of the available screen space, in dp units, corresponding to screen height resource qualifier.intscreenLayoutBit mask of overall layout of the screen.static intSCREENLAYOUT_COMPAT_NEEDEDSpecial flag we generate to indicate that the screen layout requires us to use a compatibility mode for apps that are not modern layout aware.static intSCREENLAYOUT_LAYOUTDIR_LTRConstant forscreenLayout: aSCREENLAYOUT_LAYOUTDIR_MASKvalue indicating that a layout dir has been set to LTR.static intSCREENLAYOUT_LAYOUTDIR_MASKConstant forscreenLayout: bits that encode the layout direction.static intSCREENLAYOUT_LAYOUTDIR_RTLConstant forscreenLayout: aSCREENLAYOUT_LAYOUTDIR_MASKvalue indicating that a layout dir has been set to RTL.static intSCREENLAYOUT_LAYOUTDIR_SHIFTConstant forscreenLayout: bits shift to get the layout direction.static intSCREENLAYOUT_LAYOUTDIR_UNDEFINEDConstant forscreenLayout: aSCREENLAYOUT_LAYOUTDIR_MASKvalue indicating that no layout dir has been set.static intSCREENLAYOUT_LONG_MASKConstant forscreenLayout: bits that encode the aspect ratio.static intSCREENLAYOUT_LONG_NOConstant forscreenLayout: aSCREENLAYOUT_LONG_MASKvalue that corresponds to the notlong resource qualifier.static intSCREENLAYOUT_LONG_UNDEFINEDConstant forscreenLayout: aSCREENLAYOUT_LONG_MASKvalue indicating that no size has been set.static intSCREENLAYOUT_LONG_YESConstant forscreenLayout: aSCREENLAYOUT_LONG_MASKvalue that corresponds to the long resource qualifier.static intSCREENLAYOUT_ROUND_MASKConstant forscreenLayout: bits that encode roundness of the screen.static intSCREENLAYOUT_ROUND_NOConstant forscreenLayout: aSCREENLAYOUT_ROUND_MASKvalue indicating that the screen does not have a rounded shape.static intSCREENLAYOUT_ROUND_SHIFTstatic intSCREENLAYOUT_ROUND_UNDEFINEDConstant forscreenLayout: aSCREENLAYOUT_ROUND_MASKvalue indicating that it is unknown whether or not the screen has a round shape.static intSCREENLAYOUT_ROUND_YESConstant forscreenLayout: aSCREENLAYOUT_ROUND_MASKvalue indicating that the screen has a rounded shape.static intSCREENLAYOUT_SIZE_LARGEConstant forscreenLayout: aSCREENLAYOUT_SIZE_MASKvalue indicating the screen is at least approximately 480x640 dp units, corresponds to the large resource qualifier.static intSCREENLAYOUT_SIZE_MASKConstant forscreenLayout: bits that encode the size.static intSCREENLAYOUT_SIZE_NORMALConstant forscreenLayout: aSCREENLAYOUT_SIZE_MASKvalue indicating the screen is at least approximately 320x470 dp units, corresponds to the normal resource qualifier.static intSCREENLAYOUT_SIZE_SMALLConstant forscreenLayout: aSCREENLAYOUT_SIZE_MASKvalue indicating the screen is at least approximately 320x426 dp units, corresponds to the small resource qualifier.static intSCREENLAYOUT_SIZE_UNDEFINEDConstant forscreenLayout: aSCREENLAYOUT_SIZE_MASKvalue indicating that no size has been set.static intSCREENLAYOUT_SIZE_XLARGEConstant forscreenLayout: aSCREENLAYOUT_SIZE_MASKvalue indicating the screen is at least approximately 720x960 dp units, corresponds to the xlarge resource qualifier.static intSCREENLAYOUT_UNDEFINEDConstant forscreenLayout: a value indicating that screenLayout is undefinedintscreenWidthDpThe current width of the available screen space, in dp units, corresponding to screen width resource qualifier.intseqstatic intSMALLEST_SCREEN_WIDTH_DP_UNDEFINEDDefault value forsmallestScreenWidthDpindicating that no width has been specified.intsmallestScreenWidthDpThe smallest screen size an application will see in normal operation, corresponding to smallest screen width resource qualifier.inttouchscreenThe kind of touch screen attached to the device.static intTOUCHSCREEN_FINGERConstant fortouchscreen, value corresponding to the finger resource qualifier.static intTOUCHSCREEN_NOTOUCHConstant fortouchscreen, value corresponding to the notouch resource qualifier.static intTOUCHSCREEN_STYLUSDeprecated.Not currently supported or used.static intTOUCHSCREEN_UNDEFINEDConstant fortouchscreen: a value indicating that no value has been set.static intUI_MODE_NIGHT_MASKConstant foruiMode: bits that encode the night mode.static intUI_MODE_NIGHT_NOConstant foruiMode: aUI_MODE_NIGHT_MASKvalue that corresponds to the notnight resource qualifier.static intUI_MODE_NIGHT_UNDEFINEDConstant foruiMode: aUI_MODE_NIGHT_MASKvalue indicating that no mode type has been set.static intUI_MODE_NIGHT_YESstatic intUI_MODE_TYPE_APPLIANCEConstant foruiMode: aUI_MODE_TYPE_MASKvalue that corresponds to the appliance resource qualifier.static intUI_MODE_TYPE_CARstatic intUI_MODE_TYPE_DESKstatic intUI_MODE_TYPE_MASKConstant foruiMode: bits that encode the mode type.static intUI_MODE_TYPE_NORMALConstant foruiMode: aUI_MODE_TYPE_MASKvalue that corresponds to no UI mode resource qualifier specified.static intUI_MODE_TYPE_TELEVISIONConstant foruiMode: aUI_MODE_TYPE_MASKvalue that corresponds to the television resource qualifier.static intUI_MODE_TYPE_UNDEFINEDConstant foruiMode: aUI_MODE_TYPE_MASKvalue indicating that no mode type has been set.static intUI_MODE_TYPE_WATCHintuiModeBit mask of the ui mode.booleanuserSetLocaleLocale should persist on setting.-
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
-
-
Constructor Summary
Constructors Constructor Description Configuration()Construct an invalid Configuration.Configuration(Configuration o)Makes a deep copy suitable for modification.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description intcompareTo(Configuration that)Compares this object to the specified object to determine their relative order.intdescribeContents()Parcelable methodsintdiff(Configuration delta)Return a bit mask of the differences between this Configuration object and the given one.booleanequals(Configuration that)booleanequals(Object that)Compares this instance with the specified object and indicates if they are equal.static ConfigurationgenerateDelta(Configuration base, Configuration change)Generate a delta Configuration betweenbaseandchange.inthashCode()Returns an integer hash code for this object.booleanisLayoutSizeAtLeast(int size)Check if the Configuration's currentscreenLayoutis at least the given size.booleanisOtherSeqNewer(Configuration other)booleanisScreenRound()Return whether the screen has a round shape.static StringlocaleToResourceQualifier(Locale locale)voidmakeDefault()Deprecated.static booleanneedNewResources(int configChanges, int interestingChanges)Determine if a new resource needs to be loaded from the bit set of configuration changes returned byupdateFrom(Configuration).voidreadFromParcel(Parcel source)static voidreadXmlAttrs(XmlPullParser parser, Configuration configOut)Reads the attributes corresponding to Configuration member fields from the Xml parser.static intreduceScreenLayout(int curLayout, int longSizeDp, int shortSizeDp)static intresetScreenLayout(int curLayout)static StringresourceQualifierString(Configuration config)Returns a string representation of the configuration that can be parsed by build tools (like AAPT).voidsetLocale(Locale loc)Set the locale.voidsetTo(Configuration o)voidsetToDefaults()Set this object to the system defaults.StringtoString()Returns a string containing a concise, human-readable description of this object.intupdateFrom(Configuration delta)Copy the fields from delta into this Configuration object, keeping track of which ones have changed.voidwriteToParcel(Parcel dest, int flags)Flatten this object in to a Parcel.static voidwriteXmlAttrs(XmlSerializer xml, Configuration config)Writes the Configuration's member fields as attributes into the XmlSerializer.
-
-
-
Field Detail
-
EMPTY
public static final Configuration EMPTY
-
fontScale
public float fontScale
Current user preference for the scaling factor for fonts, relative to the base density scaling.
-
mcc
public int mcc
IMSI MCC (Mobile Country Code), corresponding to mcc resource qualifier. 0 if undefined.
-
mnc
public int mnc
-
MNC_ZERO
public static final int MNC_ZERO
Constant used to to represent MNC (Mobile Network Code) zero. 0 cannot be used, since it is used to represent an undefined MNC.- See Also:
- Constant Field Values
-
locale
public Locale locale
Current user preference for the locale, corresponding to locale resource qualifier.
-
userSetLocale
public boolean userSetLocale
Locale should persist on setting. This is hidden because it is really questionable whether this is the right way to expose the functionality.
-
SCREENLAYOUT_SIZE_MASK
public static final int SCREENLAYOUT_SIZE_MASK
Constant forscreenLayout: bits that encode the size.- See Also:
- Constant Field Values
-
SCREENLAYOUT_SIZE_UNDEFINED
public static final int SCREENLAYOUT_SIZE_UNDEFINED
Constant forscreenLayout: aSCREENLAYOUT_SIZE_MASKvalue indicating that no size has been set.- See Also:
- Constant Field Values
-
SCREENLAYOUT_SIZE_SMALL
public static final int SCREENLAYOUT_SIZE_SMALL
Constant forscreenLayout: aSCREENLAYOUT_SIZE_MASKvalue indicating the screen is at least approximately 320x426 dp units, corresponds to the small resource qualifier. See Supporting Multiple Screens for more information.- See Also:
- Constant Field Values
-
SCREENLAYOUT_SIZE_NORMAL
public static final int SCREENLAYOUT_SIZE_NORMAL
Constant forscreenLayout: aSCREENLAYOUT_SIZE_MASKvalue indicating the screen is at least approximately 320x470 dp units, corresponds to the normal resource qualifier. See Supporting Multiple Screens for more information.- See Also:
- Constant Field Values
-
SCREENLAYOUT_SIZE_LARGE
public static final int SCREENLAYOUT_SIZE_LARGE
Constant forscreenLayout: aSCREENLAYOUT_SIZE_MASKvalue indicating the screen is at least approximately 480x640 dp units, corresponds to the large resource qualifier. See Supporting Multiple Screens for more information.- See Also:
- Constant Field Values
-
SCREENLAYOUT_SIZE_XLARGE
public static final int SCREENLAYOUT_SIZE_XLARGE
Constant forscreenLayout: aSCREENLAYOUT_SIZE_MASKvalue indicating the screen is at least approximately 720x960 dp units, corresponds to the xlarge resource qualifier. See Supporting Multiple Screens for more information.- See Also:
- Constant Field Values
-
SCREENLAYOUT_LONG_MASK
public static final int SCREENLAYOUT_LONG_MASK
Constant forscreenLayout: bits that encode the aspect ratio.- See Also:
- Constant Field Values
-
SCREENLAYOUT_LONG_UNDEFINED
public static final int SCREENLAYOUT_LONG_UNDEFINED
Constant forscreenLayout: aSCREENLAYOUT_LONG_MASKvalue indicating that no size has been set.- See Also:
- Constant Field Values
-
SCREENLAYOUT_LONG_NO
public static final int SCREENLAYOUT_LONG_NO
Constant forscreenLayout: aSCREENLAYOUT_LONG_MASKvalue that corresponds to the notlong resource qualifier.- See Also:
- Constant Field Values
-
SCREENLAYOUT_LONG_YES
public static final int SCREENLAYOUT_LONG_YES
Constant forscreenLayout: aSCREENLAYOUT_LONG_MASKvalue that corresponds to the long resource qualifier.- See Also:
- Constant Field Values
-
SCREENLAYOUT_LAYOUTDIR_MASK
public static final int SCREENLAYOUT_LAYOUTDIR_MASK
Constant forscreenLayout: bits that encode the layout direction.- See Also:
- Constant Field Values
-
SCREENLAYOUT_LAYOUTDIR_SHIFT
public static final int SCREENLAYOUT_LAYOUTDIR_SHIFT
Constant forscreenLayout: bits shift to get the layout direction.- See Also:
- Constant Field Values
-
SCREENLAYOUT_LAYOUTDIR_UNDEFINED
public static final int SCREENLAYOUT_LAYOUTDIR_UNDEFINED
Constant forscreenLayout: aSCREENLAYOUT_LAYOUTDIR_MASKvalue indicating that no layout dir has been set.- See Also:
- Constant Field Values
-
SCREENLAYOUT_LAYOUTDIR_LTR
public static final int SCREENLAYOUT_LAYOUTDIR_LTR
Constant forscreenLayout: aSCREENLAYOUT_LAYOUTDIR_MASKvalue indicating that a layout dir has been set to LTR.- See Also:
- Constant Field Values
-
SCREENLAYOUT_LAYOUTDIR_RTL
public static final int SCREENLAYOUT_LAYOUTDIR_RTL
Constant forscreenLayout: aSCREENLAYOUT_LAYOUTDIR_MASKvalue indicating that a layout dir has been set to RTL.- See Also:
- Constant Field Values
-
SCREENLAYOUT_ROUND_MASK
public static final int SCREENLAYOUT_ROUND_MASK
Constant forscreenLayout: bits that encode roundness of the screen.- See Also:
- Constant Field Values
-
SCREENLAYOUT_ROUND_SHIFT
public static final int SCREENLAYOUT_ROUND_SHIFT
- See Also:
- Constant Field Values
-
SCREENLAYOUT_ROUND_UNDEFINED
public static final int SCREENLAYOUT_ROUND_UNDEFINED
Constant forscreenLayout: aSCREENLAYOUT_ROUND_MASKvalue indicating that it is unknown whether or not the screen has a round shape.- See Also:
- Constant Field Values
-
SCREENLAYOUT_ROUND_NO
public static final int SCREENLAYOUT_ROUND_NO
Constant forscreenLayout: aSCREENLAYOUT_ROUND_MASKvalue indicating that the screen does not have a rounded shape.- See Also:
- Constant Field Values
-
SCREENLAYOUT_ROUND_YES
public static final int SCREENLAYOUT_ROUND_YES
Constant forscreenLayout: aSCREENLAYOUT_ROUND_MASKvalue indicating that the screen has a rounded shape. Corners may not be visible to the user; developers should pay special attention to theandroid.view.WindowInsetsdelivered to views for more information about ensuring content is not obscured.Corresponds to the
-roundresource qualifier.- See Also:
- Constant Field Values
-
SCREENLAYOUT_UNDEFINED
public static final int SCREENLAYOUT_UNDEFINED
Constant forscreenLayout: a value indicating that screenLayout is undefined- See Also:
- Constant Field Values
-
SCREENLAYOUT_COMPAT_NEEDED
public static final int SCREENLAYOUT_COMPAT_NEEDED
Special flag we generate to indicate that the screen layout requires us to use a compatibility mode for apps that are not modern layout aware.- See Also:
- Constant Field Values
-
screenLayout
public int screenLayout
Bit mask of overall layout of the screen. Currently there are two fields:The
SCREENLAYOUT_SIZE_MASKbits define the overall size of the screen. They may be one ofSCREENLAYOUT_SIZE_SMALL,SCREENLAYOUT_SIZE_NORMAL,SCREENLAYOUT_SIZE_LARGE, orSCREENLAYOUT_SIZE_XLARGE.The
SCREENLAYOUT_LONG_MASKdefines whether the screen is wider/taller than normal. They may be one ofSCREENLAYOUT_LONG_NOorSCREENLAYOUT_LONG_YES.The
SCREENLAYOUT_LAYOUTDIR_MASKdefines whether the screen layout is either LTR or RTL. They may be one ofSCREENLAYOUT_LAYOUTDIR_LTRorSCREENLAYOUT_LAYOUTDIR_RTL.The
SCREENLAYOUT_ROUND_MASKdefines whether the screen has a rounded shape. They may be one ofSCREENLAYOUT_ROUND_NOorSCREENLAYOUT_ROUND_YES.See Supporting Multiple Screens for more information.
-
TOUCHSCREEN_UNDEFINED
public static final int TOUCHSCREEN_UNDEFINED
Constant fortouchscreen: a value indicating that no value has been set.- See Also:
- Constant Field Values
-
TOUCHSCREEN_NOTOUCH
public static final int TOUCHSCREEN_NOTOUCH
Constant fortouchscreen, value corresponding to the notouch resource qualifier.- See Also:
- Constant Field Values
-
TOUCHSCREEN_STYLUS
@Deprecated public static final int TOUCHSCREEN_STYLUS
Deprecated.Not currently supported or used.- See Also:
- Constant Field Values
-
TOUCHSCREEN_FINGER
public static final int TOUCHSCREEN_FINGER
Constant fortouchscreen, value corresponding to the finger resource qualifier.- See Also:
- Constant Field Values
-
touchscreen
public int touchscreen
The kind of touch screen attached to the device. One of:TOUCHSCREEN_NOTOUCH,TOUCHSCREEN_FINGER.
-
KEYBOARD_UNDEFINED
public static final int KEYBOARD_UNDEFINED
Constant forkeyboard: a value indicating that no value has been set.- See Also:
- Constant Field Values
-
KEYBOARD_NOKEYS
public static final int KEYBOARD_NOKEYS
- See Also:
- Constant Field Values
-
KEYBOARD_QWERTY
public static final int KEYBOARD_QWERTY
- See Also:
- Constant Field Values
-
KEYBOARD_12KEY
public static final int KEYBOARD_12KEY
- See Also:
- Constant Field Values
-
keyboard
public int keyboard
The kind of keyboard attached to the device. One of:KEYBOARD_NOKEYS,KEYBOARD_QWERTY,KEYBOARD_12KEY.
-
KEYBOARDHIDDEN_UNDEFINED
public static final int KEYBOARDHIDDEN_UNDEFINED
Constant forkeyboardHidden: a value indicating that no value has been set.- See Also:
- Constant Field Values
-
KEYBOARDHIDDEN_NO
public static final int KEYBOARDHIDDEN_NO
Constant forkeyboardHidden, value corresponding to the keysexposed resource qualifier.- See Also:
- Constant Field Values
-
KEYBOARDHIDDEN_YES
public static final int KEYBOARDHIDDEN_YES
Constant forkeyboardHidden, value corresponding to the keyshidden resource qualifier.- See Also:
- Constant Field Values
-
KEYBOARDHIDDEN_SOFT
public static final int KEYBOARDHIDDEN_SOFT
Constant matching actual resource implementation.- See Also:
- Constant Field Values
-
keyboardHidden
public int keyboardHidden
A flag indicating whether any keyboard is available. UnlikehardKeyboardHidden, this also takes into account a soft keyboard, so if the hard keyboard is hidden but there is soft keyboard available, it will be set to NO. Value is one of:KEYBOARDHIDDEN_NO,KEYBOARDHIDDEN_YES.
-
HARDKEYBOARDHIDDEN_UNDEFINED
public static final int HARDKEYBOARDHIDDEN_UNDEFINED
Constant forhardKeyboardHidden: a value indicating that no value has been set.- See Also:
- Constant Field Values
-
HARDKEYBOARDHIDDEN_NO
public static final int HARDKEYBOARDHIDDEN_NO
Constant forhardKeyboardHidden, value corresponding to the physical keyboard being exposed.- See Also:
- Constant Field Values
-
HARDKEYBOARDHIDDEN_YES
public static final int HARDKEYBOARDHIDDEN_YES
Constant forhardKeyboardHidden, value corresponding to the physical keyboard being hidden.- See Also:
- Constant Field Values
-
hardKeyboardHidden
public int hardKeyboardHidden
A flag indicating whether the hard keyboard has been hidden. This will be set on a device with a mechanism to hide the keyboard from the user, when that mechanism is closed. One of:HARDKEYBOARDHIDDEN_NO,HARDKEYBOARDHIDDEN_YES.
-
NAVIGATION_UNDEFINED
public static final int NAVIGATION_UNDEFINED
Constant fornavigation: a value indicating that no value has been set.- See Also:
- Constant Field Values
-
NAVIGATION_NONAV
public static final int NAVIGATION_NONAV
Constant fornavigation, value corresponding to the nonav resource qualifier.- See Also:
- Constant Field Values
-
NAVIGATION_DPAD
public static final int NAVIGATION_DPAD
Constant fornavigation, value corresponding to the dpad resource qualifier.- See Also:
- Constant Field Values
-
NAVIGATION_TRACKBALL
public static final int NAVIGATION_TRACKBALL
Constant fornavigation, value corresponding to the trackball resource qualifier.- See Also:
- Constant Field Values
-
NAVIGATION_WHEEL
public static final int NAVIGATION_WHEEL
Constant fornavigation, value corresponding to the wheel resource qualifier.- See Also:
- Constant Field Values
-
navigation
public int navigation
The kind of navigation method available on the device. One of:NAVIGATION_NONAV,NAVIGATION_DPAD,NAVIGATION_TRACKBALL,NAVIGATION_WHEEL.
-
NAVIGATIONHIDDEN_UNDEFINED
public static final int NAVIGATIONHIDDEN_UNDEFINED
Constant fornavigationHidden: a value indicating that no value has been set.- See Also:
- Constant Field Values
-
NAVIGATIONHIDDEN_NO
public static final int NAVIGATIONHIDDEN_NO
Constant fornavigationHidden, value corresponding to the navexposed resource qualifier.- See Also:
- Constant Field Values
-
NAVIGATIONHIDDEN_YES
public static final int NAVIGATIONHIDDEN_YES
Constant fornavigationHidden, value corresponding to the navhidden resource qualifier.- See Also:
- Constant Field Values
-
navigationHidden
public int navigationHidden
A flag indicating whether any 5-way or DPAD navigation available. This will be set on a device with a mechanism to hide the navigation controls from the user, when that mechanism is closed. One of:NAVIGATIONHIDDEN_NO,NAVIGATIONHIDDEN_YES.
-
ORIENTATION_UNDEFINED
public static final int ORIENTATION_UNDEFINED
Constant fororientation: a value indicating that no value has been set.- See Also:
- Constant Field Values
-
ORIENTATION_PORTRAIT
public static final int ORIENTATION_PORTRAIT
Constant fororientation, value corresponding to the port resource qualifier.- See Also:
- Constant Field Values
-
ORIENTATION_LANDSCAPE
public static final int ORIENTATION_LANDSCAPE
Constant fororientation, value corresponding to the land resource qualifier.- See Also:
- Constant Field Values
-
ORIENTATION_SQUARE
@Deprecated public static final int ORIENTATION_SQUARE
Deprecated.Not currently supported or used.- See Also:
- Constant Field Values
-
orientation
public int orientation
Overall orientation of the screen. May be one ofORIENTATION_LANDSCAPE,ORIENTATION_PORTRAIT.
-
UI_MODE_TYPE_MASK
public static final int UI_MODE_TYPE_MASK
Constant foruiMode: bits that encode the mode type.- See Also:
- Constant Field Values
-
UI_MODE_TYPE_UNDEFINED
public static final int UI_MODE_TYPE_UNDEFINED
Constant foruiMode: aUI_MODE_TYPE_MASKvalue indicating that no mode type has been set.- See Also:
- Constant Field Values
-
UI_MODE_TYPE_NORMAL
public static final int UI_MODE_TYPE_NORMAL
Constant foruiMode: aUI_MODE_TYPE_MASKvalue that corresponds to no UI mode resource qualifier specified.- See Also:
- Constant Field Values
-
UI_MODE_TYPE_DESK
public static final int UI_MODE_TYPE_DESK
- See Also:
- Constant Field Values
-
UI_MODE_TYPE_CAR
public static final int UI_MODE_TYPE_CAR
- See Also:
- Constant Field Values
-
UI_MODE_TYPE_TELEVISION
public static final int UI_MODE_TYPE_TELEVISION
Constant foruiMode: aUI_MODE_TYPE_MASKvalue that corresponds to the television resource qualifier.- See Also:
- Constant Field Values
-
UI_MODE_TYPE_APPLIANCE
public static final int UI_MODE_TYPE_APPLIANCE
Constant foruiMode: aUI_MODE_TYPE_MASKvalue that corresponds to the appliance resource qualifier.- See Also:
- Constant Field Values
-
UI_MODE_TYPE_WATCH
public static final int UI_MODE_TYPE_WATCH
- See Also:
- Constant Field Values
-
UI_MODE_NIGHT_MASK
public static final int UI_MODE_NIGHT_MASK
Constant foruiMode: bits that encode the night mode.- See Also:
- Constant Field Values
-
UI_MODE_NIGHT_UNDEFINED
public static final int UI_MODE_NIGHT_UNDEFINED
Constant foruiMode: aUI_MODE_NIGHT_MASKvalue indicating that no mode type has been set.- See Also:
- Constant Field Values
-
UI_MODE_NIGHT_NO
public static final int UI_MODE_NIGHT_NO
Constant foruiMode: aUI_MODE_NIGHT_MASKvalue that corresponds to the notnight resource qualifier.- See Also:
- Constant Field Values
-
UI_MODE_NIGHT_YES
public static final int UI_MODE_NIGHT_YES
- See Also:
- Constant Field Values
-
uiMode
public int uiMode
Bit mask of the ui mode. Currently there are two fields:The
UI_MODE_TYPE_MASKbits define the overall ui mode of the device. They may be one ofUI_MODE_TYPE_UNDEFINED,UI_MODE_TYPE_NORMAL,UI_MODE_TYPE_DESK,UI_MODE_TYPE_CAR,UI_MODE_TYPE_TELEVISION,UI_MODE_TYPE_APPLIANCE, orUI_MODE_TYPE_WATCH.The
UI_MODE_NIGHT_MASKdefines whether the screen is in a special mode. They may be one ofUI_MODE_NIGHT_UNDEFINED,UI_MODE_NIGHT_NOorUI_MODE_NIGHT_YES.
-
SCREEN_WIDTH_DP_UNDEFINED
public static final int SCREEN_WIDTH_DP_UNDEFINED
Default value forscreenWidthDpindicating that no width has been specified.- See Also:
- Constant Field Values
-
screenWidthDp
public int screenWidthDp
The current width of the available screen space, in dp units, corresponding to screen width resource qualifier. Set toSCREEN_WIDTH_DP_UNDEFINEDif no width is specified.
-
SCREEN_HEIGHT_DP_UNDEFINED
public static final int SCREEN_HEIGHT_DP_UNDEFINED
Default value forscreenHeightDpindicating that no width has been specified.- See Also:
- Constant Field Values
-
screenHeightDp
public int screenHeightDp
The current height of the available screen space, in dp units, corresponding to screen height resource qualifier. Set toSCREEN_HEIGHT_DP_UNDEFINEDif no height is specified.
-
SMALLEST_SCREEN_WIDTH_DP_UNDEFINED
public static final int SMALLEST_SCREEN_WIDTH_DP_UNDEFINED
Default value forsmallestScreenWidthDpindicating that no width has been specified.- See Also:
- Constant Field Values
-
smallestScreenWidthDp
public int smallestScreenWidthDp
The smallest screen size an application will see in normal operation, corresponding to smallest screen width resource qualifier. This is the smallest value of both screenWidthDp and screenHeightDp in both portrait and landscape. Set toSMALLEST_SCREEN_WIDTH_DP_UNDEFINEDif no width is specified.
-
DENSITY_DPI_UNDEFINED
public static final int DENSITY_DPI_UNDEFINED
Default value fordensityDpiindicating that no width has been specified.- See Also:
- Constant Field Values
-
DENSITY_DPI_ANY
public static final int DENSITY_DPI_ANY
Value fordensityDpifor resources that scale to any density (vector drawables).- See Also:
- Constant Field Values
-
DENSITY_DPI_NONE
public static final int DENSITY_DPI_NONE
Value fordensityDpifor resources that are not meant to be scaled.- See Also:
- Constant Field Values
-
densityDpi
public int densityDpi
The target screen density being rendered to, corresponding to density resource qualifier. Set toDENSITY_DPI_UNDEFINEDif no density is specified.
-
compatScreenWidthDp
public int compatScreenWidthDp
-
compatScreenHeightDp
public int compatScreenHeightDp
-
compatSmallestScreenWidthDp
public int compatSmallestScreenWidthDp
-
seq
public int seq
-
NATIVE_CONFIG_MCC
public static final int NATIVE_CONFIG_MCC
- See Also:
- Constant Field Values
-
NATIVE_CONFIG_MNC
public static final int NATIVE_CONFIG_MNC
- See Also:
- Constant Field Values
-
NATIVE_CONFIG_LOCALE
public static final int NATIVE_CONFIG_LOCALE
- See Also:
- Constant Field Values
-
NATIVE_CONFIG_TOUCHSCREEN
public static final int NATIVE_CONFIG_TOUCHSCREEN
- See Also:
- Constant Field Values
-
NATIVE_CONFIG_KEYBOARD
public static final int NATIVE_CONFIG_KEYBOARD
- See Also:
- Constant Field Values
-
NATIVE_CONFIG_KEYBOARD_HIDDEN
public static final int NATIVE_CONFIG_KEYBOARD_HIDDEN
- See Also:
- Constant Field Values
-
NATIVE_CONFIG_NAVIGATION
public static final int NATIVE_CONFIG_NAVIGATION
- See Also:
- Constant Field Values
-
NATIVE_CONFIG_ORIENTATION
public static final int NATIVE_CONFIG_ORIENTATION
- See Also:
- Constant Field Values
-
NATIVE_CONFIG_DENSITY
public static final int NATIVE_CONFIG_DENSITY
- See Also:
- Constant Field Values
-
NATIVE_CONFIG_SCREEN_SIZE
public static final int NATIVE_CONFIG_SCREEN_SIZE
- See Also:
- Constant Field Values
-
NATIVE_CONFIG_VERSION
public static final int NATIVE_CONFIG_VERSION
- See Also:
- Constant Field Values
-
NATIVE_CONFIG_SCREEN_LAYOUT
public static final int NATIVE_CONFIG_SCREEN_LAYOUT
- See Also:
- Constant Field Values
-
NATIVE_CONFIG_UI_MODE
public static final int NATIVE_CONFIG_UI_MODE
- See Also:
- Constant Field Values
-
NATIVE_CONFIG_SMALLEST_SCREEN_SIZE
public static final int NATIVE_CONFIG_SMALLEST_SCREEN_SIZE
- See Also:
- Constant Field Values
-
NATIVE_CONFIG_LAYOUTDIR
public static final int NATIVE_CONFIG_LAYOUTDIR
- See Also:
- Constant Field Values
-
CREATOR
public static final Parcelable.Creator<Configuration> CREATOR
-
-
Constructor Detail
-
Configuration
public Configuration()
Construct an invalid Configuration. You must callsetToDefaults()for this object to be valid.
-
Configuration
public Configuration(Configuration o)
Makes a deep copy suitable for modification.
-
-
Method Detail
-
resetScreenLayout
public static int resetScreenLayout(int curLayout)
-
reduceScreenLayout
public static int reduceScreenLayout(int curLayout, int longSizeDp, int shortSizeDp)
-
isLayoutSizeAtLeast
public boolean isLayoutSizeAtLeast(int size)
Check if the Configuration's currentscreenLayoutis at least the given size.- Parameters:
size- The desired size, eitherSCREENLAYOUT_SIZE_SMALL,SCREENLAYOUT_SIZE_NORMAL,SCREENLAYOUT_SIZE_LARGE, orSCREENLAYOUT_SIZE_XLARGE.- Returns:
- Returns true if the current screen layout size is at least the given size.
-
setTo
public void setTo(Configuration o)
-
toString
public String toString()
Description copied from class:ObjectReturns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:getClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toStringmethod if you intend implementing your owntoStringmethod.
-
setToDefaults
public void setToDefaults()
Set this object to the system defaults.
-
makeDefault
@Deprecated public void makeDefault()
Deprecated.
-
updateFrom
public int updateFrom(Configuration delta)
Copy the fields from delta into this Configuration object, keeping track of which ones have changed. Any undefined fields in delta are ignored and not copied in to the current Configuration.- Returns:
- Returns a bit mask of the changed fields, as per
diff(android.content.res.Configuration).
-
diff
public int diff(Configuration delta)
Return a bit mask of the differences between this Configuration object and the given one. Does not change the values of either. Any undefined fields in delta are ignored.- Returns:
- Returns a bit mask indicating which configuration
values has changed, containing any combination of
PackageManager.ActivityInfo.CONFIG_FONT_SCALE,PackageManager.ActivityInfo.CONFIG_MCC,PackageManager.ActivityInfo.CONFIG_MNC,PackageManager.ActivityInfo.CONFIG_LOCALE,PackageManager.ActivityInfo.CONFIG_TOUCHSCREEN,PackageManager.ActivityInfo.CONFIG_KEYBOARD,PackageManager.ActivityInfo.CONFIG_NAVIGATION,PackageManager.ActivityInfo.CONFIG_ORIENTATION,PackageManager.ActivityInfo.CONFIG_SCREEN_LAYOUT, orPackageManager.ActivityInfo.CONFIG_SCREEN_SIZE, orPackageManager.ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE.PackageManager.ActivityInfo.CONFIG_LAYOUT_DIRECTION.
-
needNewResources
public static boolean needNewResources(int configChanges, int interestingChanges)Determine if a new resource needs to be loaded from the bit set of configuration changes returned byupdateFrom(Configuration).- Parameters:
configChanges- The mask of changes configurations as returned byupdateFrom(Configuration).interestingChanges- The configuration changes that the resource can handled, as given inTypedValue.changingConfigurations.- Returns:
- Return true if the resource needs to be loaded, else false.
-
isOtherSeqNewer
public boolean isOtherSeqNewer(Configuration other)
-
describeContents
public int describeContents()
Parcelable methods- Specified by:
describeContentsin interfaceParcelable- Returns:
- a bitmask indicating the set of special object types marshalled by the Parcelable.
-
writeToParcel
public void writeToParcel(Parcel dest, int flags)
Description copied from interface:ParcelableFlatten this object in to a Parcel.- Specified by:
writeToParcelin interfaceParcelable- Parameters:
dest- The Parcel in which the object should be written.flags- Additional flags about how the object should be written. May be 0 orParcelable.PARCELABLE_WRITE_RETURN_VALUE.
-
readFromParcel
public void readFromParcel(Parcel source)
-
compareTo
public int compareTo(Configuration that)
Description copied from interface:ComparableCompares this object to the specified object to determine their relative order.- Specified by:
compareToin interfaceComparable<Configuration>- Parameters:
that- the object to compare to this instance.- Returns:
- a negative integer if this instance is less than
another; a positive integer if this instance is greater thananother; 0 if this instance has the same order asanother.
-
equals
public boolean equals(Configuration that)
-
equals
public boolean equals(Object that)
Description copied from class:ObjectCompares this instance with the specified object and indicates if they are equal. In order to be equal,omust represent the same object as this instance using a class-specific comparison. The general contract is that this comparison should be reflexive, symmetric, and transitive. Also, no object reference other than null is equal to null.The default implementation returns
trueonly ifthis == o. See Writing a correctequalsmethod if you intend implementing your ownequalsmethod.The general contract for the
equalsandObject.hashCode()methods is that ifequalsreturnstruefor any two objects, thenhashCode()must return the same value for these objects. This means that subclasses ofObjectusually override either both methods or neither of them.- Overrides:
equalsin classObject- Parameters:
that- the object to compare this instance with.- Returns:
trueif the specified object is equal to thisObject;falseotherwise.- See Also:
Object.hashCode()
-
hashCode
public int hashCode()
Description copied from class:ObjectReturns an integer hash code for this object. By contract, any two objects for whichObject.equals(java.lang.Object)returnstruemust return the same hash code value. This means that subclasses ofObjectusually override both methods or neither method.Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCodemethod if you intend implementing your ownhashCodemethod.- Overrides:
hashCodein classObject- Returns:
- this object's hash code.
- See Also:
Object.equals(java.lang.Object)
-
setLocale
public void setLocale(Locale loc)
Set the locale. This is the preferred way for setting up the locale (instead of using the direct accessor). This will also set the layout direction according to the locale.- Parameters:
loc- The locale. Can be null.
-
isScreenRound
public boolean isScreenRound()
Return whether the screen has a round shape. Apps may choose to change styling based on this property, such as the alignment or layout of text or informational icons.- Returns:
- true if the screen is rounded, false otherwise
-
resourceQualifierString
public static String resourceQualifierString(Configuration config)
Returns a string representation of the configuration that can be parsed by build tools (like AAPT).
-
generateDelta
public static Configuration generateDelta(Configuration base, Configuration change)
Generate a delta Configuration betweenbaseandchange. The resulting delta can be used withupdateFrom(Configuration). Caveat: If the any of the Configuration's members becomes undefined, thenupdateFrom(Configuration)will treat it as a no-op and not update that member. This is fine for device configurations as no member is ever undefined.
-
readXmlAttrs
public static void readXmlAttrs(XmlPullParser parser, Configuration configOut) throws XmlPullParserException, IOException
Reads the attributes corresponding to Configuration member fields from the Xml parser. The parser is expected to be on a tag which has Configuration attributes.- Parameters:
parser- The Xml parser from which to read attributes.configOut- The Configuration to populate from the Xml attributes.- Throws:
XmlPullParserExceptionIOException
-
writeXmlAttrs
public static void writeXmlAttrs(XmlSerializer xml, Configuration config) throws IOException
Writes the Configuration's member fields as attributes into the XmlSerializer. The serializer is expected to have already started a tag so that attributes can be immediately written.- Parameters:
xml- The serializer to which to write the attributes.config- The Configuration whose member fields to write.- Throws:
IOException
-
-