public final class Configuration
extends Object
implements Parcelable, Comparable<Configuration>
java.lang.Object | |
↳ | 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 getConfiguration()
. Thus, from an activity, you can get it by chaining the request with getResources()
:
Configuration config = getResources().getConfiguration();
Constants |
|
---|---|
int |
DENSITY_DPI_UNDEFINED Default value for |
int |
HARDKEYBOARDHIDDEN_NO Constant for |
int |
HARDKEYBOARDHIDDEN_UNDEFINED Constant for |
int |
HARDKEYBOARDHIDDEN_YES Constant for |
int |
KEYBOARDHIDDEN_NO Constant for |
int |
KEYBOARDHIDDEN_UNDEFINED Constant for |
int |
KEYBOARDHIDDEN_YES Constant for |
int |
KEYBOARD_12KEY Constant for |
int |
KEYBOARD_NOKEYS Constant for |
int |
KEYBOARD_QWERTY Constant for |
int |
KEYBOARD_UNDEFINED Constant for |
int |
MNC_ZERO Constant used to to represent MNC (Mobile Network Code) zero. |
int |
NAVIGATIONHIDDEN_NO Constant for |
int |
NAVIGATIONHIDDEN_UNDEFINED Constant for |
int |
NAVIGATIONHIDDEN_YES Constant for |
int |
NAVIGATION_DPAD Constant for |
int |
NAVIGATION_NONAV Constant for |
int |
NAVIGATION_TRACKBALL Constant for |
int |
NAVIGATION_UNDEFINED Constant for |
int |
NAVIGATION_WHEEL Constant for |
int |
ORIENTATION_LANDSCAPE Constant for |
int |
ORIENTATION_PORTRAIT Constant for |
int |
ORIENTATION_SQUARE This constant was deprecated in API level 16. Not currently supported or used. |
int |
ORIENTATION_UNDEFINED Constant for |
int |
SCREENLAYOUT_LAYOUTDIR_LTR Constant for |
int |
SCREENLAYOUT_LAYOUTDIR_MASK Constant for |
int |
SCREENLAYOUT_LAYOUTDIR_RTL Constant for |
int |
SCREENLAYOUT_LAYOUTDIR_SHIFT Constant for |
int |
SCREENLAYOUT_LAYOUTDIR_UNDEFINED Constant for |
int |
SCREENLAYOUT_LONG_MASK Constant for |
int |
SCREENLAYOUT_LONG_NO Constant for |
int |
SCREENLAYOUT_LONG_UNDEFINED Constant for |
int |
SCREENLAYOUT_LONG_YES Constant for |
int |
SCREENLAYOUT_ROUND_MASK Constant for |
int |
SCREENLAYOUT_ROUND_NO Constant for |
int |
SCREENLAYOUT_ROUND_UNDEFINED Constant for |
int |
SCREENLAYOUT_ROUND_YES Constant for |
int |
SCREENLAYOUT_SIZE_LARGE Constant for |
int |
SCREENLAYOUT_SIZE_MASK Constant for |
int |
SCREENLAYOUT_SIZE_NORMAL Constant for |
int |
SCREENLAYOUT_SIZE_SMALL Constant for |
int |
SCREENLAYOUT_SIZE_UNDEFINED Constant for |
int |
SCREENLAYOUT_SIZE_XLARGE Constant for |
int |
SCREENLAYOUT_UNDEFINED Constant for |
int |
SCREEN_HEIGHT_DP_UNDEFINED Default value for |
int |
SCREEN_WIDTH_DP_UNDEFINED Default value for |
int |
SMALLEST_SCREEN_WIDTH_DP_UNDEFINED Default value for |
int |
TOUCHSCREEN_FINGER Constant for |
int |
TOUCHSCREEN_NOTOUCH Constant for |
int |
TOUCHSCREEN_STYLUS This constant was deprecated in API level 16. Not currently supported or used. |
int |
TOUCHSCREEN_UNDEFINED Constant for |
int |
UI_MODE_NIGHT_MASK Constant for |
int |
UI_MODE_NIGHT_NO Constant for |
int |
UI_MODE_NIGHT_UNDEFINED Constant for |
int |
UI_MODE_NIGHT_YES Constant for |
int |
UI_MODE_TYPE_APPLIANCE Constant for |
int |
UI_MODE_TYPE_CAR Constant for |
int |
UI_MODE_TYPE_DESK Constant for |
int |
UI_MODE_TYPE_MASK Constant for |
int |
UI_MODE_TYPE_NORMAL Constant for |
int |
UI_MODE_TYPE_TELEVISION Constant for |
int |
UI_MODE_TYPE_UNDEFINED Constant for |
int |
UI_MODE_TYPE_WATCH Constant for |
Inherited constants |
---|
![]() android.os.Parcelable
|
Fields |
|
---|---|
public static final Creator<Configuration> |
CREATOR
|
public int |
densityDpi The target screen density being rendered to, corresponding to density resource qualifier. |
public float |
fontScale Current user preference for the scaling factor for fonts, relative to the base density scaling. |
public int |
hardKeyboardHidden A flag indicating whether the hard keyboard has been hidden. |
public int |
keyboard The kind of keyboard attached to the device. |
public int |
keyboardHidden A flag indicating whether any keyboard is available. |
public Locale |
locale This field was deprecated in API level 24. Do not set or read this directly. Use |
public int |
mcc IMSI MCC (Mobile Country Code), corresponding to mcc resource qualifier. |
public int |
mnc IMSI MNC (Mobile Network Code), corresponding to mnc resource qualifier. |
public int |
navigation The kind of navigation method available on the device. |
public int |
navigationHidden A flag indicating whether any 5-way or DPAD navigation available. |
public int |
orientation Overall orientation of the screen. |
public int |
screenHeightDp The current height of the available screen space, in dp units, corresponding to screen height resource qualifier. |
public int |
screenLayout Bit mask of overall layout of the screen. |
public int |
screenWidthDp The current width of the available screen space, in dp units, corresponding to screen width resource qualifier. |
public int |
smallestScreenWidthDp The smallest screen size an application will see in normal operation, corresponding to smallest screen width resource qualifier. |
public int |
touchscreen The kind of touch screen attached to the device. |
public int |
uiMode Bit mask of the ui mode. |
Public constructors |
|
---|---|
Configuration() Construct an invalid Configuration. You must call |
|
Configuration(Configuration o) Makes a deep copy suitable for modification. |
Public methods |
|
---|---|
int |
compareTo(Configuration that) |
int |
describeContents() Parcelable methods |
int |
diff(Configuration delta) Return a bit mask of the differences between this Configuration object and the given one. |
boolean |
equals(Configuration that) |
boolean |
equals(Object that) Indicates whether some other object is "equal to" this one. |
int |
getLayoutDirection() Return the layout direction. |
LocaleList |
getLocales() Get the locale list. |
int |
hashCode() Returns a hash code value for the object. |
boolean |
isLayoutSizeAtLeast(int size) Check if the Configuration's current |
boolean |
isScreenRound() Return whether the screen has a round shape. |
static boolean |
needNewResources(int configChanges, int interestingChanges) Determines if a new resource needs to be loaded from the bit set of configuration changes returned by |
void |
readFromParcel(Parcel source) |
void |
setLayoutDirection(Locale loc) Set the layout direction from a Locale. |
void |
setLocale(Locale loc) Set the locale list to a list of just one locale. |
void |
setLocales(LocaleList locales) Set the locale list. |
void |
setTo(Configuration o) |
void |
setToDefaults() Set this object to the system defaults. |
String |
toString() Returns a string representation of the object. |
int |
updateFrom(Configuration delta) Copies the fields from delta into this Configuration object, keeping track of which ones have changed. |
void |
writeToParcel(Parcel dest, int flags) Flatten this object in to a Parcel. |
Inherited methods |
|
---|---|
![]() java.lang.Object
|
|
![]() android.os.Parcelable
|
|
![]() java.lang.Comparable
|
int DENSITY_DPI_UNDEFINED
Default value for densityDpi
indicating that no width has been specified.
Constant Value: 0 (0x00000000)
int HARDKEYBOARDHIDDEN_NO
Constant for hardKeyboardHidden
, value corresponding to the physical keyboard being exposed.
Constant Value: 1 (0x00000001)
int HARDKEYBOARDHIDDEN_UNDEFINED
Constant for hardKeyboardHidden
: a value indicating that no value has been set.
Constant Value: 0 (0x00000000)
int HARDKEYBOARDHIDDEN_YES
Constant for hardKeyboardHidden
, value corresponding to the physical keyboard being hidden.
Constant Value: 2 (0x00000002)
int KEYBOARDHIDDEN_NO
Constant for keyboardHidden
, value corresponding to the keysexposed resource qualifier.
Constant Value: 1 (0x00000001)
int KEYBOARDHIDDEN_UNDEFINED
Constant for keyboardHidden
: a value indicating that no value has been set.
Constant Value: 0 (0x00000000)
int KEYBOARDHIDDEN_YES
Constant for keyboardHidden
, value corresponding to the keyshidden resource qualifier.
Constant Value: 2 (0x00000002)
int KEYBOARD_12KEY
Constant for keyboard
, value corresponding to the 12key resource qualifier.
Constant Value: 3 (0x00000003)
int KEYBOARD_NOKEYS
Constant for keyboard
, value corresponding to the nokeys resource qualifier.
Constant Value: 1 (0x00000001)
int KEYBOARD_QWERTY
Constant for keyboard
, value corresponding to the qwerty resource qualifier.
Constant Value: 2 (0x00000002)
int KEYBOARD_UNDEFINED
Constant for keyboard
: a value indicating that no value has been set.
Constant Value: 0 (0x00000000)
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.
Constant Value: 65535 (0x0000ffff)
int NAVIGATIONHIDDEN_NO
Constant for navigationHidden
, value corresponding to the navexposed resource qualifier.
Constant Value: 1 (0x00000001)
int NAVIGATIONHIDDEN_UNDEFINED
Constant for navigationHidden
: a value indicating that no value has been set.
Constant Value: 0 (0x00000000)
int NAVIGATIONHIDDEN_YES
Constant for navigationHidden
, value corresponding to the navhidden resource qualifier.
Constant Value: 2 (0x00000002)
int NAVIGATION_DPAD
Constant for navigation
, value corresponding to the dpad resource qualifier.
Constant Value: 2 (0x00000002)
int NAVIGATION_NONAV
Constant for navigation
, value corresponding to the nonav resource qualifier.
Constant Value: 1 (0x00000001)
int NAVIGATION_TRACKBALL
Constant for navigation
, value corresponding to the trackball resource qualifier.
Constant Value: 3 (0x00000003)
int NAVIGATION_UNDEFINED
Constant for navigation
: a value indicating that no value has been set.
Constant Value: 0 (0x00000000)
int NAVIGATION_WHEEL
Constant for navigation
, value corresponding to the wheel resource qualifier.
Constant Value: 4 (0x00000004)
int ORIENTATION_LANDSCAPE
Constant for orientation
, value corresponding to the land resource qualifier.
Constant Value: 2 (0x00000002)
int ORIENTATION_PORTRAIT
Constant for orientation
, value corresponding to the port resource qualifier.
Constant Value: 1 (0x00000001)
int ORIENTATION_SQUARE
This constant was deprecated in API level 16.
Not currently supported or used.
Constant Value: 3 (0x00000003)
int ORIENTATION_UNDEFINED
Constant for orientation
: a value indicating that no value has been set.
Constant Value: 0 (0x00000000)
int SCREENLAYOUT_LAYOUTDIR_LTR
Constant for screenLayout
: a SCREENLAYOUT_LAYOUTDIR_MASK
value indicating that a layout dir has been set to LTR.
Constant Value: 64 (0x00000040)
int SCREENLAYOUT_LAYOUTDIR_MASK
Constant for screenLayout
: bits that encode the layout direction.
Constant Value: 192 (0x000000c0)
int SCREENLAYOUT_LAYOUTDIR_RTL
Constant for screenLayout
: a SCREENLAYOUT_LAYOUTDIR_MASK
value indicating that a layout dir has been set to RTL.
Constant Value: 128 (0x00000080)
int SCREENLAYOUT_LAYOUTDIR_SHIFT
Constant for screenLayout
: bits shift to get the layout direction.
Constant Value: 6 (0x00000006)
int SCREENLAYOUT_LAYOUTDIR_UNDEFINED
Constant for screenLayout
: a SCREENLAYOUT_LAYOUTDIR_MASK
value indicating that no layout dir has been set.
Constant Value: 0 (0x00000000)
int SCREENLAYOUT_LONG_MASK
Constant for screenLayout
: bits that encode the aspect ratio.
Constant Value: 48 (0x00000030)
int SCREENLAYOUT_LONG_NO
Constant for screenLayout
: a SCREENLAYOUT_LONG_MASK
value that corresponds to the notlong resource qualifier.
Constant Value: 16 (0x00000010)
int SCREENLAYOUT_LONG_UNDEFINED
Constant for screenLayout
: a SCREENLAYOUT_LONG_MASK
value indicating that no size has been set.
Constant Value: 0 (0x00000000)
int SCREENLAYOUT_LONG_YES
Constant for screenLayout
: a SCREENLAYOUT_LONG_MASK
value that corresponds to the long resource qualifier.
Constant Value: 32 (0x00000020)
int SCREENLAYOUT_ROUND_MASK
Constant for screenLayout
: bits that encode roundness of the screen.
Constant Value: 768 (0x00000300)
int SCREENLAYOUT_ROUND_NO
Constant for screenLayout
: a SCREENLAYOUT_ROUND_MASK
value indicating that the screen does not have a rounded shape.
Constant Value: 256 (0x00000100)
int SCREENLAYOUT_ROUND_UNDEFINED
Constant for screenLayout
: a SCREENLAYOUT_ROUND_MASK
value indicating that it is unknown whether or not the screen has a round shape.
Constant Value: 0 (0x00000000)
int SCREENLAYOUT_ROUND_YES
Constant for screenLayout
: a SCREENLAYOUT_ROUND_MASK
value indicating that the screen has a rounded shape. Corners may not be visible to the user; developers should pay special attention to the WindowInsets
delivered to views for more information about ensuring content is not obscured.
Corresponds to the -round
resource qualifier.
Constant Value: 512 (0x00000200)
int SCREENLAYOUT_SIZE_LARGE
Constant for screenLayout
: a SCREENLAYOUT_SIZE_MASK
value indicating the screen is at least approximately 480x640 dp units, corresponds to the large resource qualifier. See Supporting Multiple Screens for more information.
Constant Value: 3 (0x00000003)
int SCREENLAYOUT_SIZE_MASK
Constant for screenLayout
: bits that encode the size.
Constant Value: 15 (0x0000000f)
int SCREENLAYOUT_SIZE_NORMAL
Constant for screenLayout
: a SCREENLAYOUT_SIZE_MASK
value indicating the screen is at least approximately 320x470 dp units, corresponds to the normal resource qualifier. See Supporting Multiple Screens for more information.
Constant Value: 2 (0x00000002)
int SCREENLAYOUT_SIZE_SMALL
Constant for screenLayout
: a SCREENLAYOUT_SIZE_MASK
value indicating the screen is at least approximately 320x426 dp units, corresponds to the small resource qualifier. See Supporting Multiple Screens for more information.
Constant Value: 1 (0x00000001)
int SCREENLAYOUT_SIZE_UNDEFINED
Constant for screenLayout
: a SCREENLAYOUT_SIZE_MASK
value indicating that no size has been set.
Constant Value: 0 (0x00000000)
int SCREENLAYOUT_SIZE_XLARGE
Constant for screenLayout
: a SCREENLAYOUT_SIZE_MASK
value indicating the screen is at least approximately 720x960 dp units, corresponds to the xlarge resource qualifier. See Supporting Multiple Screens for more information.
Constant Value: 4 (0x00000004)
int SCREENLAYOUT_UNDEFINED
Constant for screenLayout
: a value indicating that screenLayout is undefined
Constant Value: 0 (0x00000000)
int SCREEN_HEIGHT_DP_UNDEFINED
Default value for screenHeightDp
indicating that no width has been specified.
Constant Value: 0 (0x00000000)
int SCREEN_WIDTH_DP_UNDEFINED
Default value for screenWidthDp
indicating that no width has been specified.
Constant Value: 0 (0x00000000)
int SMALLEST_SCREEN_WIDTH_DP_UNDEFINED
Default value for smallestScreenWidthDp
indicating that no width has been specified.
Constant Value: 0 (0x00000000)
int TOUCHSCREEN_FINGER
Constant for touchscreen
, value corresponding to the finger resource qualifier.
Constant Value: 3 (0x00000003)
int TOUCHSCREEN_NOTOUCH
Constant for touchscreen
, value corresponding to the notouch resource qualifier.
Constant Value: 1 (0x00000001)
int TOUCHSCREEN_STYLUS
This constant was deprecated in API level 16.
Not currently supported or used.
Constant Value: 2 (0x00000002)
int TOUCHSCREEN_UNDEFINED
Constant for touchscreen
: a value indicating that no value has been set.
Constant Value: 0 (0x00000000)
int UI_MODE_NIGHT_MASK
Constant for uiMode
: bits that encode the night mode.
Constant Value: 48 (0x00000030)
int UI_MODE_NIGHT_NO
Constant for uiMode
: a UI_MODE_NIGHT_MASK
value that corresponds to the notnight resource qualifier.
Constant Value: 16 (0x00000010)
int UI_MODE_NIGHT_UNDEFINED
Constant for uiMode
: a UI_MODE_NIGHT_MASK
value indicating that no mode type has been set.
Constant Value: 0 (0x00000000)
int UI_MODE_NIGHT_YES
Constant for uiMode
: a UI_MODE_NIGHT_MASK
value that corresponds to the night resource qualifier.
Constant Value: 32 (0x00000020)
int UI_MODE_TYPE_APPLIANCE
Constant for uiMode
: a UI_MODE_TYPE_MASK
value that corresponds to the appliance resource qualifier.
Constant Value: 5 (0x00000005)
int UI_MODE_TYPE_CAR
Constant for uiMode
: a UI_MODE_TYPE_MASK
value that corresponds to the car resource qualifier.
Constant Value: 3 (0x00000003)
int UI_MODE_TYPE_DESK
Constant for uiMode
: a UI_MODE_TYPE_MASK
value that corresponds to the desk resource qualifier.
Constant Value: 2 (0x00000002)
int UI_MODE_TYPE_MASK
Constant for uiMode
: bits that encode the mode type.
Constant Value: 15 (0x0000000f)
int UI_MODE_TYPE_NORMAL
Constant for uiMode
: a UI_MODE_TYPE_MASK
value that corresponds to no UI mode resource qualifier specified.
Constant Value: 1 (0x00000001)
int UI_MODE_TYPE_TELEVISION
Constant for uiMode
: a UI_MODE_TYPE_MASK
value that corresponds to the television resource qualifier.
Constant Value: 4 (0x00000004)
int UI_MODE_TYPE_UNDEFINED
Constant for uiMode
: a UI_MODE_TYPE_MASK
value indicating that no mode type has been set.
Constant Value: 0 (0x00000000)
int UI_MODE_TYPE_WATCH
Constant for uiMode
: a UI_MODE_TYPE_MASK
value that corresponds to the watch resource qualifier.
Constant Value: 6 (0x00000006)
int densityDpi
The target screen density being rendered to, corresponding to density resource qualifier. Set to DENSITY_DPI_UNDEFINED
if no density is specified.
float fontScale
Current user preference for the scaling factor for fonts, relative to the base density scaling.
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
.
int keyboard
The kind of keyboard attached to the device. One of: KEYBOARD_NOKEYS
, KEYBOARD_QWERTY
, KEYBOARD_12KEY
.
int keyboardHidden
A flag indicating whether any keyboard is available. Unlike hardKeyboardHidden
, 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
.
Locale locale
This field was deprecated in API level 24.
Do not set or read this directly. Use getLocales()
and setLocales(LocaleList)
. If only the primary locale is needed, getLocales().get(0)
is now the preferred accessor.
Current user preference for the locale, corresponding to locale resource qualifier.
int mcc
IMSI MCC (Mobile Country Code), corresponding to mcc resource qualifier. 0 if undefined.
int mnc
IMSI MNC (Mobile Network Code), corresponding to mnc resource qualifier. 0 if undefined. Note that the actual MNC may be 0; in order to check for this use the MNC_ZERO
symbol.
int navigation
The kind of navigation method available on the device. One of: NAVIGATION_NONAV
, NAVIGATION_DPAD
, NAVIGATION_TRACKBALL
, NAVIGATION_WHEEL
.
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
.
int orientation
Overall orientation of the screen. May be one of ORIENTATION_LANDSCAPE
, ORIENTATION_PORTRAIT
.
int screenHeightDp
The current height of the available screen space, in dp units, corresponding to screen height resource qualifier. Set to SCREEN_HEIGHT_DP_UNDEFINED
if no height is specified.
int screenLayout
Bit mask of overall layout of the screen. Currently there are four fields:
The SCREENLAYOUT_SIZE_MASK
bits define the overall size of the screen. They may be one of SCREENLAYOUT_SIZE_SMALL
, SCREENLAYOUT_SIZE_NORMAL
, SCREENLAYOUT_SIZE_LARGE
, or SCREENLAYOUT_SIZE_XLARGE
.
The SCREENLAYOUT_LONG_MASK
defines whether the screen is wider/taller than normal. They may be one of SCREENLAYOUT_LONG_NO
or SCREENLAYOUT_LONG_YES
.
The SCREENLAYOUT_LAYOUTDIR_MASK
defines whether the screen layout is either LTR or RTL. They may be one of SCREENLAYOUT_LAYOUTDIR_LTR
or SCREENLAYOUT_LAYOUTDIR_RTL
.
The SCREENLAYOUT_ROUND_MASK
defines whether the screen has a rounded shape. They may be one of SCREENLAYOUT_ROUND_NO
or SCREENLAYOUT_ROUND_YES
.
See Supporting Multiple Screens for more information.
int screenWidthDp
The current width of the available screen space, in dp units, corresponding to screen width resource qualifier. Set to SCREEN_WIDTH_DP_UNDEFINED
if no width is specified.
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 to SMALLEST_SCREEN_WIDTH_DP_UNDEFINED
if no width is specified.
int touchscreen
The kind of touch screen attached to the device. One of: TOUCHSCREEN_NOTOUCH
, TOUCHSCREEN_FINGER
.
int uiMode
Bit mask of the ui mode. Currently there are two fields:
The UI_MODE_TYPE_MASK
bits define the overall ui mode of the device. They may be one of UI_MODE_TYPE_UNDEFINED
, UI_MODE_TYPE_NORMAL
, UI_MODE_TYPE_DESK
, UI_MODE_TYPE_CAR
, UI_MODE_TYPE_TELEVISION
, UI_MODE_TYPE_APPLIANCE
, or UI_MODE_TYPE_WATCH
.
The UI_MODE_NIGHT_MASK
defines whether the screen is in a special mode. They may be one of UI_MODE_NIGHT_UNDEFINED
, UI_MODE_NIGHT_NO
or UI_MODE_NIGHT_YES
.
Configuration ()
Construct an invalid Configuration. You must call setToDefaults()
for this object to be valid.
Configuration (Configuration o)
Makes a deep copy suitable for modification.
Parameters | |
---|---|
o |
Configuration
|
int compareTo (Configuration that)
Parameters | |
---|---|
that |
Configuration
|
Returns | |
---|---|
int |
int describeContents ()
Parcelable methods
Returns | |
---|---|
int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. |
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.
Parameters | |
---|---|
delta |
Configuration
|
Returns | |
---|---|
int |
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 , or PackageManager.ActivityInfo.CONFIG_SCREEN_SIZE , or PackageManager.ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE . PackageManager.ActivityInfo.CONFIG_LAYOUT_DIRECTION . |
boolean equals (Configuration that)
Parameters | |
---|---|
that |
Configuration
|
Returns | |
---|---|
boolean |
boolean equals (Object that)
Indicates whether some other object is "equal to" this one.
The equals
method implements an equivalence relation on non-null object references:
x
, x.equals(x)
should return true
. x
and y
, x.equals(y)
should return true
if and only if y.equals(x)
returns true
. x
, y
, and z
, if x.equals(y)
returns true
and y.equals(z)
returns true
, then x.equals(z)
should return true
. x
and y
, multiple invocations of x.equals(y)
consistently return true
or consistently return false
, provided no information used in equals
comparisons on the objects is modified. x
, x.equals(null)
should return false
. The equals
method for class Object
implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x
and y
, this method returns true
if and only if x
and y
refer to the same object (x == y
has the value true
).
Note that it is generally necessary to override the hashCode
method whenever this method is overridden, so as to maintain the general contract for the hashCode
method, which states that equal objects must have equal hash codes.
Parameters | |
---|---|
that |
Object : the reference object with which to compare. |
Returns | |
---|---|
boolean |
true if this object is the same as the obj argument; false otherwise. |
int getLayoutDirection ()
Return the layout direction. Will be either LAYOUT_DIRECTION_LTR
or LAYOUT_DIRECTION_RTL
.
Returns | |
---|---|
int |
Returns LAYOUT_DIRECTION_RTL if the configuration is SCREENLAYOUT_LAYOUTDIR_RTL , otherwise LAYOUT_DIRECTION_LTR . |
LocaleList getLocales ()
Get the locale list. This is the preferred way for getting the locales (instead of using the direct accessor to locale
, which would only provide the primary locale).
Returns | |
---|---|
LocaleList |
The locale list. |
int hashCode ()
Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap
.
The general contract of hashCode
is:
hashCode
method must consistently return the same integer, provided no information used in equals
comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. equals(Object)
method, then calling the hashCode
method on each of the two objects must produce the same integer result. equals(java.lang.Object)
method, then calling the hashCode
method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables. As much as is reasonably practical, the hashCode method defined by class Object
does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)
Returns | |
---|---|
int |
a hash code value for this object. |
boolean isLayoutSizeAtLeast (int size)
Check if the Configuration's current screenLayout
is at least the given size.
Parameters | |
---|---|
size |
int : The desired size, either SCREENLAYOUT_SIZE_SMALL , SCREENLAYOUT_SIZE_NORMAL , SCREENLAYOUT_SIZE_LARGE , or SCREENLAYOUT_SIZE_XLARGE . |
Returns | |
---|---|
boolean |
Returns true if the current screen layout size is at least the given size. |
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 | |
---|---|
boolean |
true if the screen is rounded, false otherwise |
boolean needNewResources (int configChanges, int interestingChanges)
Determines if a new resource needs to be loaded from the bit set of configuration changes returned by updateFrom(Configuration)
.
Parameters | |
---|---|
configChanges |
int : the mask of changes configurations as returned by updateFrom(Configuration) |
interestingChanges |
int : the configuration changes that the resource can handle as given in changingConfigurations |
Returns | |
---|---|
boolean |
true if the resource needs to be loaded, false otherwise |
void setLayoutDirection (Locale loc)
Set the layout direction from a Locale.
Parameters | |
---|---|
loc |
Locale : The Locale. If null will set the layout direction to LAYOUT_DIRECTION_LTR . If not null will set it to the layout direction corresponding to the Locale. |
See also:
void setLocale (Locale loc)
Set the locale list to a list of just one locale. This will also set the layout direction according to the locale. Note that after this is run, calling .equals()
on the input locale and the locale
attribute would return true
if they are not null, but there is no guarantee that they would be the same object. See also the note about layout direction in setLocales(LocaleList)
.
Parameters | |
---|---|
loc |
Locale : The locale. Can be null. |
void setLocales (LocaleList locales)
Set the locale list. This is the preferred way for setting up the locales (instead of using the direct accessor or setLocale(Locale)
). This will also set the layout direction according to the first locale in the list. Note that the layout direction will always come from the first locale in the locale list, even if the locale is not supported by the resources (the resources may only support another locale further down the list which has a different direction).
Parameters | |
---|---|
locales |
LocaleList : The locale list. If null, an empty LocaleList will be assigned. |
String toString ()
Returns a string representation of the object. In general, the toString
method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@
', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Returns | |
---|---|
String |
a string representation of the object. |
int updateFrom (Configuration delta)
Copies 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.
Parameters | |
---|---|
delta |
Configuration
|
Returns | |
---|---|
int |
a bit mask of the changed fields, as per diff(Configuration) |
void writeToParcel (Parcel dest, int flags)
Flatten this object in to a Parcel.
Parameters | |
---|---|
dest |
Parcel : The Parcel in which the object should be written. |
flags |
int : Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE . |