Added in API level 1

Configuration


class Configuration : Comparable<Configuration!>, Parcelable
kotlin.Any
   ↳ android.content.res.Configuration

This class describes all device configuration information that can impact the resources the application retrieves. This includes both user-specified configuration options (locale list and scaling) as well as device configurations (such as input modes, screen size and screen orientation).

You can acquire this object from Resources, using Resources.getConfiguration. Thus, from an activity, you can get it by chaining the request with android.app.Activity#getResources:

Configuration config = getResources().getConfiguration();

Summary

Constants
static Int

Constant for colorMode: bits that encode the dynamic range of the screen.

static Int

Constant for colorMode: a COLOR_MODE_HDR_MASK value indicating that the screen is not HDR (low/standard dynamic range).

static Int

Constant for colorMode: bits shift to get the screen dynamic range.

static Int

Constant for colorMode: a COLOR_MODE_HDR_MASK value indicating that it is unknown whether or not the screen is HDR.

static Int

Constant for colorMode: a COLOR_MODE_HDR_MASK value indicating that the screen is HDR (dynamic range).

static Int

Constant for colorMode: a value indicating that the color mode is undefined

static Int

Constant for colorMode: bits that encode whether the screen is wide gamut.

static Int

Constant for colorMode: a COLOR_MODE_WIDE_COLOR_GAMUT_MASK value indicating that the screen is not wide gamut.

static Int

Constant for colorMode: a COLOR_MODE_WIDE_COLOR_GAMUT_MASK value indicating that it is unknown whether or not the screen is wide gamut.

static Int

Constant for colorMode: a COLOR_MODE_WIDE_COLOR_GAMUT_MASK value indicating that the screen is wide gamut.

static Int

Default value for densityDpi indicating that no width has been specified.

static Int

An undefined fontWeightAdjustment.

static Int

Constant for grammatical gender: to indicate the terms of address the user preferred in an application is feminine.

static Int

Constant for grammatical gender: to indicate the terms of address the user preferred in an application is masculine.

static Int

Constant for grammatical gender: to indicate the terms of address the user preferred in an application is neuter.

static Int

Constant for grammatical gender: to indicate the user has not specified the terms of address for the application.

static Int

Constant for hardKeyboardHidden, value corresponding to the physical keyboard being exposed.

static Int

Constant for hardKeyboardHidden: a value indicating that no value has been set.

static Int

Constant for hardKeyboardHidden, value corresponding to the physical keyboard being hidden.

static Int

Constant for keyboardHidden, value corresponding to the keysexposed resource qualifier.

static Int

Constant for keyboardHidden: a value indicating that no value has been set.

static Int

Constant for keyboardHidden, value corresponding to the keyshidden resource qualifier.

static Int

Constant for keyboard, value corresponding to the 12key resource qualifier.

static Int

Constant for keyboard, value corresponding to the nokeys resource qualifier.

static Int

Constant for keyboard, value corresponding to the qwerty resource qualifier.

static Int

Constant for keyboard: a value indicating that no value has been set.

static Int

Constant used to to represent MNC (Mobile Network Code) zero.

static Int

Constant for navigationHidden, value corresponding to the navexposed resource qualifier.

static Int

Constant for navigationHidden: a value indicating that no value has been set.

static Int

Constant for navigationHidden, value corresponding to the navhidden resource qualifier.

static Int

Constant for navigation, value corresponding to the dpad resource qualifier.

static Int

Constant for navigation, value corresponding to the nonav resource qualifier.

static Int

Constant for navigation, value corresponding to the trackball resource qualifier.

static Int

Constant for navigation: a value indicating that no value has been set.

static Int

Constant for navigation, value corresponding to the wheel resource qualifier.

static Int

Constant for orientation, value corresponding to the land resource qualifier.

static Int

Constant for orientation, value corresponding to the port resource qualifier.

static Int

static Int

Constant for orientation: a value indicating that no value has been set.

static Int

Constant for screenLayout: a SCREENLAYOUT_LAYOUTDIR_MASK value indicating that a layout dir has been set to LTR.

static Int

Constant for screenLayout: bits that encode the layout direction.

static Int

Constant for screenLayout: a SCREENLAYOUT_LAYOUTDIR_MASK value indicating that a layout dir has been set to RTL.

static Int

Constant for screenLayout: bits shift to get the layout direction.

static Int

Constant for screenLayout: a SCREENLAYOUT_LAYOUTDIR_MASK value indicating that no layout dir has been set.

static Int

Constant for screenLayout: bits that encode the aspect ratio.

static Int

Constant for screenLayout: a SCREENLAYOUT_LONG_MASK value that corresponds to the notlong resource qualifier.

static Int

Constant for screenLayout: a SCREENLAYOUT_LONG_MASK value indicating that no size has been set.

static Int

Constant for screenLayout: a SCREENLAYOUT_LONG_MASK value that corresponds to the long resource qualifier.

static Int

Constant for screenLayout: bits that encode roundness of the screen.

static Int

Constant for screenLayout: a SCREENLAYOUT_ROUND_MASK value indicating that the screen does not have a rounded shape.

static Int

Constant for screenLayout: a SCREENLAYOUT_ROUND_MASK value indicating that it is unknown whether or not the screen has a round shape.

static Int

Constant for screenLayout: a SCREENLAYOUT_ROUND_MASK value indicating that the screen has a rounded shape.

static Int

Constant for screenLayout: a SCREENLAYOUT_SIZE_MASK value indicating the screen is at least approximately 480x640 dp units, corresponds to the large resource qualifier.

static Int

Constant for screenLayout: bits that encode the size.

static Int

Constant for screenLayout: a SCREENLAYOUT_SIZE_MASK value indicating the screen is at least approximately 320x470 dp units, corresponds to the normal resource qualifier.

static Int

Constant for screenLayout: a SCREENLAYOUT_SIZE_MASK value indicating the screen is at least approximately 320x426 dp units, corresponds to the small resource qualifier.

static Int

Constant for screenLayout: a SCREENLAYOUT_SIZE_MASK value indicating that no size has been set.

static Int

Constant for screenLayout: a SCREENLAYOUT_SIZE_MASK value indicating the screen is at least approximately 720x960 dp units, corresponds to the xlarge resource qualifier.

static Int

Constant for screenLayout: a value indicating that screenLayout is undefined

static Int

Default value for screenHeightDp indicating that no width has been specified.

static Int

Default value for screenWidthDp indicating that no width has been specified.

static Int

Default value for smallestScreenWidthDp indicating that no width has been specified.

static Int

Constant for touchscreen, value corresponding to the finger resource qualifier.

static Int

Constant for touchscreen, value corresponding to the notouch resource qualifier.

static Int

static Int

Constant for touchscreen: a value indicating that no value has been set.

static Int

Constant for uiMode: bits that encode the night mode.

static Int

Constant for uiMode: a UI_MODE_NIGHT_MASK value that corresponds to the notnight resource qualifier.

static Int

Constant for uiMode: a UI_MODE_NIGHT_MASK value indicating that no mode type has been set.

static Int

Constant for uiMode: a UI_MODE_NIGHT_MASK value that corresponds to the night resource qualifier.

static Int

Constant for uiMode: a UI_MODE_TYPE_MASK value that corresponds to the appliance resource qualifier.

static Int

Constant for uiMode: a UI_MODE_TYPE_MASK value that corresponds to the car resource qualifier.

static Int

Constant for uiMode: a UI_MODE_TYPE_MASK value that corresponds to the desk resource qualifier.

static Int

Constant for uiMode: bits that encode the mode type.

static Int

Constant for uiMode: a UI_MODE_TYPE_MASK value that corresponds to no UI mode resource qualifier specified.

static Int

Constant for uiMode: a UI_MODE_TYPE_MASK value that corresponds to the television resource qualifier.

static Int

Constant for uiMode: a UI_MODE_TYPE_MASK value indicating that no mode type has been set.

static Int

Constant for uiMode: a UI_MODE_TYPE_MASK value that corresponds to the vrheadset resource qualifier.

static Int

Constant for uiMode: a UI_MODE_TYPE_MASK value that corresponds to the watch resource qualifier.

Inherited constants
Public constructors

Construct an invalid Configuration.

Makes a deep copy suitable for modification.

Public methods
Int

Compares this object with the specified object for order.

Int

Parcelable methods

Int

Return a bit mask of the differences between this Configuration object and the given one.

Boolean

Boolean
equals(other: Any?)

Indicates whether some other object is "equal to" this one.

static Configuration

Generate a delta Configuration between base and change.

Int

Returns the user preference for the grammatical gender.

Int

Return the layout direction.

LocaleList

Get the locale list.

Int

Returns a hash code value for the object.

Boolean

Check if the Configuration's current screenLayout is at least the given size.

Boolean

Retuns whether the configuration is in night mode

Boolean

Return whether the screen has a high dynamic range.

Boolean

Return whether the screen has a round shape.

Boolean

Return whether the screen has a wide color gamut and wide color gamut rendering is supported by this device.

static Boolean
needNewResources(configChanges: Int, interestingChanges: Int)

Determines if a new resource needs to be loaded from the bit set of configuration changes returned by updateFrom(Configuration).

Unit

Unit

Set the layout direction from a Locale.

Unit

Set the locale list to a list of just one locale.

Unit

Set the locale list.

Unit

Sets the fields in this object to those in the given Configuration.

Unit

Set this object to the system defaults.

String

Returns a string representation of the object.

Int

Copies the fields from delta into this Configuration object, keeping track of which ones have changed.

Unit
writeToParcel(dest: Parcel, flags: Int)

Flatten this object in to a Parcel.

Properties
static Parcelable.Creator<Configuration!>

Int

Bit mask of color capabilities of the screen.

Int

The target screen density being rendered to, corresponding to density resource qualifier.

Float

Current user preference for the scaling factor for fonts, relative to the base density scaling.

Int

Adjustment in text font weight.

Int

A flag indicating whether the hard keyboard has been hidden.

Int

The kind of keyboard attached to the device.

Int

A flag indicating whether any keyboard is available.

Locale!

Current user preference for the locale, corresponding to locale resource qualifier.

Int

IMSI MCC (Mobile Country Code), corresponding to mcc resource qualifier.

Int

IMSI MNC (Mobile Network Code), corresponding to mnc resource qualifier.

Int

The kind of navigation method available on the device.

Int

A flag indicating whether any 5-way or DPAD navigation available.

Int

Overall orientation of the screen.

Int

The height of the available screen space in dp units.

Int

Bit mask of overall layout of the screen.

Int

The width of the available screen space in dp units.

Int

The smallest screen size an application will see in normal operation.

Int

The kind of touch screen attached to the device.

Int

Bit mask of the ui mode.

Constants

COLOR_MODE_HDR_MASK

Added in API level 26
static val COLOR_MODE_HDR_MASK: Int

Constant for colorMode: bits that encode the dynamic range of the screen.

Value: 12

COLOR_MODE_HDR_NO

Added in API level 26
static val COLOR_MODE_HDR_NO: Int

Constant for colorMode: a COLOR_MODE_HDR_MASK value indicating that the screen is not HDR (low/standard dynamic range).

Corresponds to the -lowdr resource qualifier.

Value: 4

COLOR_MODE_HDR_SHIFT

Added in API level 26
static val COLOR_MODE_HDR_SHIFT: Int

Constant for colorMode: bits shift to get the screen dynamic range.

Value: 2

COLOR_MODE_HDR_UNDEFINED

Added in API level 26
static val COLOR_MODE_HDR_UNDEFINED: Int

Constant for colorMode: a COLOR_MODE_HDR_MASK value indicating that it is unknown whether or not the screen is HDR.

Value: 0

COLOR_MODE_HDR_YES

Added in API level 26
static val COLOR_MODE_HDR_YES: Int

Constant for colorMode: a COLOR_MODE_HDR_MASK value indicating that the screen is HDR (dynamic range).

Corresponds to the -highdr resource qualifier.

Value: 8

COLOR_MODE_UNDEFINED

Added in API level 26
static val COLOR_MODE_UNDEFINED: Int

Constant for colorMode: a value indicating that the color mode is undefined

Value: 0

COLOR_MODE_WIDE_COLOR_GAMUT_MASK

Added in API level 26
static val COLOR_MODE_WIDE_COLOR_GAMUT_MASK: Int

Constant for colorMode: bits that encode whether the screen is wide gamut.

Value: 3

COLOR_MODE_WIDE_COLOR_GAMUT_NO

Added in API level 26
static val COLOR_MODE_WIDE_COLOR_GAMUT_NO: Int

Constant for colorMode: a COLOR_MODE_WIDE_COLOR_GAMUT_MASK value indicating that the screen is not wide gamut.

Corresponds to the -nowidecg resource qualifier.

Value: 1

COLOR_MODE_WIDE_COLOR_GAMUT_UNDEFINED

Added in API level 26
static val COLOR_MODE_WIDE_COLOR_GAMUT_UNDEFINED: Int

Constant for colorMode: a COLOR_MODE_WIDE_COLOR_GAMUT_MASK value indicating that it is unknown whether or not the screen is wide gamut.

Value: 0

COLOR_MODE_WIDE_COLOR_GAMUT_YES

Added in API level 26
static val COLOR_MODE_WIDE_COLOR_GAMUT_YES: Int

Constant for colorMode: a COLOR_MODE_WIDE_COLOR_GAMUT_MASK value indicating that the screen is wide gamut.

Corresponds to the -widecg resource qualifier.

Value: 2

DENSITY_DPI_UNDEFINED

Added in API level 17
static val DENSITY_DPI_UNDEFINED: Int

Default value for densityDpi indicating that no width has been specified.

Value: 0

FONT_WEIGHT_ADJUSTMENT_UNDEFINED

Added in API level 31
static val FONT_WEIGHT_ADJUSTMENT_UNDEFINED: Int

An undefined fontWeightAdjustment.

Value: 2147483647

GRAMMATICAL_GENDER_FEMININE

Added in API level 34
static val GRAMMATICAL_GENDER_FEMININE: Int

Constant for grammatical gender: to indicate the terms of address the user preferred in an application is feminine.

Value: 2

GRAMMATICAL_GENDER_MASCULINE

Added in API level 34
static val GRAMMATICAL_GENDER_MASCULINE: Int

Constant for grammatical gender: to indicate the terms of address the user preferred in an application is masculine.

Value: 3