public final class Configuration extends Object implements Parcelable, Comparable<Configuration>
You can acquire this object from Resources
, using Resources.getConfiguration()
. Thus, from an activity, you can get it by chaining the request
with ContextThemeWrapper.getResources()
:
Configuration config = getResources().getConfiguration();
Modifier and Type | Class and Description |
---|---|
static interface |
Configuration.NativeConfig |
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
int |
compatScreenHeightDp |
int |
compatScreenWidthDp |
int |
compatSmallestScreenWidthDp |
static Parcelable.Creator<Configuration> |
CREATOR |
static int |
DENSITY_DPI_ANY
Value for
densityDpi for resources that scale to any density (vector drawables). |
static int |
DENSITY_DPI_NONE
Value for
densityDpi for resources that are not meant to be scaled. |
static int |
DENSITY_DPI_UNDEFINED
Default value for
densityDpi indicating that no width
has been specified. |
int |
densityDpi
The target screen density being rendered to,
corresponding to
density
resource qualifier.
|
static Configuration |
EMPTY |
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.
|
static int |
HARDKEYBOARDHIDDEN_NO
Constant for
hardKeyboardHidden , value corresponding to the
physical keyboard being exposed. |
static int |
HARDKEYBOARDHIDDEN_UNDEFINED
Constant for
hardKeyboardHidden : a value indicating that no value has been set. |
static int |
HARDKEYBOARDHIDDEN_YES
Constant for
hardKeyboardHidden , value corresponding to the
physical keyboard being hidden. |
int |
keyboard
The kind of keyboard attached to the device.
|
static int |
KEYBOARD_12KEY
|
static int |
KEYBOARD_NOKEYS
|
static int |
KEYBOARD_QWERTY
|
static int |
KEYBOARD_UNDEFINED
Constant for
keyboard : a value indicating that no value has been set. |
int |
keyboardHidden
A flag indicating whether any keyboard is available.
|
static int |
KEYBOARDHIDDEN_NO
Constant for
keyboardHidden , value corresponding to the
keysexposed
resource qualifier. |
static int |
KEYBOARDHIDDEN_SOFT
Constant matching actual resource implementation.
|
static int |
KEYBOARDHIDDEN_UNDEFINED
Constant for
keyboardHidden : a value indicating that no value has been set. |
static int |
KEYBOARDHIDDEN_YES
Constant for
keyboardHidden , value corresponding to the
keyshidden
resource qualifier. |
Locale |
locale
Deprecated.
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. |
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.
|
static 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.
|
static int |
NATIVE_CONFIG_DENSITY |
static int |
NATIVE_CONFIG_KEYBOARD |
static int |
NATIVE_CONFIG_KEYBOARD_HIDDEN |
static int |
NATIVE_CONFIG_LAYOUTDIR |
static int |
NATIVE_CONFIG_LOCALE |
static int |
NATIVE_CONFIG_MCC |
static int |
NATIVE_CONFIG_MNC |
static int |
NATIVE_CONFIG_NAVIGATION |
static int |
NATIVE_CONFIG_ORIENTATION |
static int |
NATIVE_CONFIG_SCREEN_LAYOUT |
static int |
NATIVE_CONFIG_SCREEN_SIZE |
static int |
NATIVE_CONFIG_SMALLEST_SCREEN_SIZE |
static int |
NATIVE_CONFIG_TOUCHSCREEN |
static int |
NATIVE_CONFIG_UI_MODE |
static int |
NATIVE_CONFIG_VERSION |
int |
navigation
The kind of navigation method available on the device.
|
static int |
NAVIGATION_DPAD
Constant for
navigation , value corresponding to the
dpad
resource qualifier. |
static int |
NAVIGATION_NONAV
Constant for
navigation , value corresponding to the
nonav
resource qualifier. |
static int |
NAVIGATION_TRACKBALL
Constant for
navigation , value corresponding to the
trackball
resource qualifier. |
static int |
NAVIGATION_UNDEFINED
Constant for
navigation : a value indicating that no value has been set. |
static int |
NAVIGATION_WHEEL
Constant for
navigation , value corresponding to the
wheel
resource qualifier. |
int |
navigationHidden
A flag indicating whether any 5-way or DPAD navigation available.
|
static int |
NAVIGATIONHIDDEN_NO
Constant for
navigationHidden , value corresponding to the
navexposed
resource qualifier. |
static int |
NAVIGATIONHIDDEN_UNDEFINED
Constant for
navigationHidden : a value indicating that no value has been set. |
static int |
NAVIGATIONHIDDEN_YES
Constant for
navigationHidden , value corresponding to the
navhidden
resource qualifier. |
int |
orientation
Overall orientation of the screen.
|
static int |
ORIENTATION_LANDSCAPE
Constant for
orientation , value corresponding to the
land
resource qualifier. |
static int |
ORIENTATION_PORTRAIT
Constant for
orientation , value corresponding to the
port
resource qualifier. |
static int |
ORIENTATION_SQUARE
Deprecated.
Not currently supported or used.
|
static int |
ORIENTATION_UNDEFINED
Constant for
orientation : a value indicating that no value has been set. |
static int |
SCREEN_HEIGHT_DP_UNDEFINED
Default value for
screenHeightDp indicating that no width
has been specified. |
static int |
SCREEN_WIDTH_DP_UNDEFINED
Default value for
screenWidthDp indicating that no width
has been specified. |
int |
screenHeightDp
The current height of the available screen space, in dp units,
corresponding to
screen
height resource qualifier.
|
int |
screenLayout
Bit mask of overall layout of the screen.
|
static 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.
|
static int |
SCREENLAYOUT_LAYOUTDIR_LTR
Constant for
screenLayout : a SCREENLAYOUT_LAYOUTDIR_MASK
value indicating that a layout dir has been set to LTR. |
static int |
SCREENLAYOUT_LAYOUTDIR_MASK
Constant for
screenLayout : bits that encode the layout direction. |
static int |
SCREENLAYOUT_LAYOUTDIR_RTL
Constant for
screenLayout : a SCREENLAYOUT_LAYOUTDIR_MASK
value indicating that a layout dir has been set to RTL. |
static int |
SCREENLAYOUT_LAYOUTDIR_SHIFT
Constant for
screenLayout : bits shift to get the layout direction. |
static int |
SCREENLAYOUT_LAYOUTDIR_UNDEFINED
Constant for
screenLayout : a SCREENLAYOUT_LAYOUTDIR_MASK
value indicating that no layout dir has been set. |
static int |
SCREENLAYOUT_LONG_MASK
Constant for
screenLayout : bits that encode the aspect ratio. |
static int |
SCREENLAYOUT_LONG_NO
Constant for
screenLayout : a SCREENLAYOUT_LONG_MASK
value that corresponds to the
notlong
resource qualifier. |
static int |
SCREENLAYOUT_LONG_UNDEFINED
Constant for
screenLayout : a SCREENLAYOUT_LONG_MASK
value indicating that no size has been set. |
static int |
SCREENLAYOUT_LONG_YES
Constant for
screenLayout : a SCREENLAYOUT_LONG_MASK
value that corresponds to the
long
resource qualifier. |
static int |
SCREENLAYOUT_ROUND_MASK
Constant for
screenLayout : bits that encode roundness of the screen. |
static int |
SCREENLAYOUT_ROUND_NO
Constant for
screenLayout : a SCREENLAYOUT_ROUND_MASK value indicating
that the screen does not have a rounded shape. |
static int |
SCREENLAYOUT_ROUND_SHIFT |
static 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. |
static int |
SCREENLAYOUT_ROUND_YES
Constant for
screenLayout : a SCREENLAYOUT_ROUND_MASK value indicating
that the screen has a rounded shape. |
static 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. |
static int |
SCREENLAYOUT_SIZE_MASK
Constant for
screenLayout : bits that encode the size. |
static 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. |
static 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. |
static int |
SCREENLAYOUT_SIZE_UNDEFINED
Constant for
screenLayout : a SCREENLAYOUT_SIZE_MASK
value indicating that no size has been set. |
static 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. |
static int |
SCREENLAYOUT_UNDEFINED
Constant for
screenLayout : a value indicating that screenLayout is undefined |
int |
screenWidthDp
The current width of the available screen space, in dp units,
corresponding to
screen
width resource qualifier.
|
int |
seq |
static int |
SMALLEST_SCREEN_WIDTH_DP_UNDEFINED
Default value for
smallestScreenWidthDp indicating that no width
has been specified. |
int |
smallestScreenWidthDp
The smallest screen size an application will see in normal operation,
corresponding to
smallest
screen width resource qualifier.
|
int |
touchscreen
The kind of touch screen attached to the device.
|
static int |
TOUCHSCREEN_FINGER
Constant for
touchscreen , value corresponding to the
finger
resource qualifier. |
static int |
TOUCHSCREEN_NOTOUCH
Constant for
touchscreen , value corresponding to the
notouch
resource qualifier. |
static int |
TOUCHSCREEN_STYLUS
Deprecated.
Not currently supported or used.
|
static int |
TOUCHSCREEN_UNDEFINED
Constant for
touchscreen : a value indicating that no value has been set. |
static int |
UI_MODE_NIGHT_MASK
Constant for
uiMode : bits that encode the night mode. |
static int |
UI_MODE_NIGHT_NO
Constant for
uiMode : a UI_MODE_NIGHT_MASK
value that corresponds to the
notnight
resource qualifier. |
static int |
UI_MODE_NIGHT_UNDEFINED
Constant for
uiMode : a UI_MODE_NIGHT_MASK
value indicating that no mode type has been set. |
static int |
UI_MODE_NIGHT_YES
|
static int |
UI_MODE_TYPE_APPLIANCE
Constant for
uiMode : a UI_MODE_TYPE_MASK
value that corresponds to the
appliance
resource qualifier. |
static int |
UI_MODE_TYPE_CAR
|
static int |
UI_MODE_TYPE_DESK
|
static int |
UI_MODE_TYPE_MASK
Constant for
uiMode : bits that encode the mode type. |
static int |
UI_MODE_TYPE_NORMAL
Constant for
uiMode : a UI_MODE_TYPE_MASK
value that corresponds to
no
UI mode resource qualifier specified. |
static int |
UI_MODE_TYPE_TELEVISION
Constant for
uiMode : a UI_MODE_TYPE_MASK
value that corresponds to the
television
resource qualifier. |
static int |
UI_MODE_TYPE_UNDEFINED
Constant for
uiMode : a UI_MODE_TYPE_MASK
value indicating that no mode type has been set. |
static int |
UI_MODE_TYPE_WATCH
|
int |
uiMode
Bit mask of the ui mode.
|
boolean |
userSetLocale
Locale should persist on setting.
|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
Configuration()
Construct an invalid Configuration.
|
Configuration(Configuration o)
Makes a deep copy suitable for modification.
|
Modifier and Type | Method and Description |
---|---|
void |
clearLocales() |
int |
compareTo(Configuration that)
Compares this object with the specified object for order.
|
static String |
configurationDiffToString(int diff) |
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.
|
static Configuration |
generateDelta(Configuration base,
Configuration change)
Generate a delta Configuration between
base and change . |
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
screenLayout is at
least the given size. |
boolean |
isOtherSeqNewer(Configuration other) |
boolean |
isScreenRound()
Return whether the screen has a round shape.
|
static String |
localesToResourceQualifier(LocaleList locs) |
void |
makeDefault()
Deprecated.
|
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
updateFrom(Configuration) . |
void |
readFromParcel(Parcel source) |
static void |
readXmlAttrs(XmlPullParser parser,
Configuration configOut)
Reads the attributes corresponding to Configuration member fields from the Xml parser.
|
static int |
reduceScreenLayout(int curLayout,
int longSizeDp,
int shortSizeDp) |
static int |
resetScreenLayout(int curLayout) |
static String |
resourceQualifierString(Configuration config)
Returns a string representation of the configuration that can be parsed
by build tools (like AAPT).
|
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.
|
static void |
writeXmlAttrs(XmlSerializer xml,
Configuration config)
Writes the Configuration's member fields as attributes into the XmlSerializer.
|
public static final Configuration EMPTY
public float fontScale
public int mcc
public int mnc
public static final int MNC_ZERO
@Deprecated public Locale locale
getLocales()
and
setLocales(LocaleList)
. If only the primary locale is needed,
getLocales().get(0)
is now the preferred accessor.public boolean userSetLocale
public static final int SCREENLAYOUT_SIZE_MASK
screenLayout
: bits that encode the size.public static final int SCREENLAYOUT_SIZE_UNDEFINED
screenLayout
: a SCREENLAYOUT_SIZE_MASK
value indicating that no size has been set.public static final int SCREENLAYOUT_SIZE_SMALL
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.public static final int SCREENLAYOUT_SIZE_NORMAL
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.public static final int SCREENLAYOUT_SIZE_LARGE
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.public static final int SCREENLAYOUT_SIZE_XLARGE
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.public static final int SCREENLAYOUT_LONG_MASK
screenLayout
: bits that encode the aspect ratio.public static final int SCREENLAYOUT_LONG_UNDEFINED
screenLayout
: a SCREENLAYOUT_LONG_MASK
value indicating that no size has been set.public static final int SCREENLAYOUT_LONG_NO
screenLayout
: a SCREENLAYOUT_LONG_MASK
value that corresponds to the
notlong
resource qualifier.public static final int SCREENLAYOUT_LONG_YES
screenLayout
: a SCREENLAYOUT_LONG_MASK
value that corresponds to the
long
resource qualifier.public static final int SCREENLAYOUT_LAYOUTDIR_MASK
screenLayout
: bits that encode the layout direction.public static final int SCREENLAYOUT_LAYOUTDIR_SHIFT
screenLayout
: bits shift to get the layout direction.public static final int SCREENLAYOUT_LAYOUTDIR_UNDEFINED
screenLayout
: a SCREENLAYOUT_LAYOUTDIR_MASK
value indicating that no layout dir has been set.public static final int SCREENLAYOUT_LAYOUTDIR_LTR
screenLayout
: a SCREENLAYOUT_LAYOUTDIR_MASK
value indicating that a layout dir has been set to LTR.public static final int SCREENLAYOUT_LAYOUTDIR_RTL
screenLayout
: a SCREENLAYOUT_LAYOUTDIR_MASK
value indicating that a layout dir has been set to RTL.public static final int SCREENLAYOUT_ROUND_MASK
screenLayout
: bits that encode roundness of the screen.public static final int SCREENLAYOUT_ROUND_SHIFT
public static final int SCREENLAYOUT_ROUND_UNDEFINED
screenLayout
: a SCREENLAYOUT_ROUND_MASK
value indicating
that it is unknown whether or not the screen has a round shape.public static final int SCREENLAYOUT_ROUND_NO
screenLayout
: a SCREENLAYOUT_ROUND_MASK
value indicating
that the screen does not have a rounded shape.public static final int SCREENLAYOUT_ROUND_YES
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.
public static final int SCREENLAYOUT_UNDEFINED
screenLayout
: a value indicating that screenLayout is undefinedpublic static final int SCREENLAYOUT_COMPAT_NEEDED
public int screenLayout
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.
public static final int TOUCHSCREEN_UNDEFINED
touchscreen
: a value indicating that no value has been set.public static final int TOUCHSCREEN_NOTOUCH
touchscreen
, value corresponding to the
notouch
resource qualifier.@Deprecated public static final int TOUCHSCREEN_STYLUS
public static final int TOUCHSCREEN_FINGER
touchscreen
, value corresponding to the
finger
resource qualifier.public int touchscreen
TOUCHSCREEN_NOTOUCH
, TOUCHSCREEN_FINGER
.public static final int KEYBOARD_UNDEFINED
keyboard
: a value indicating that no value has been set.public static final int KEYBOARD_NOKEYS
public static final int KEYBOARD_QWERTY
public static final int KEYBOARD_12KEY
public int keyboard
KEYBOARD_NOKEYS
, KEYBOARD_QWERTY
,
KEYBOARD_12KEY
.public static final int KEYBOARDHIDDEN_UNDEFINED
keyboardHidden
: a value indicating that no value has been set.public static final int KEYBOARDHIDDEN_NO
keyboardHidden
, value corresponding to the
keysexposed
resource qualifier.public static final int KEYBOARDHIDDEN_YES
keyboardHidden
, value corresponding to the
keyshidden
resource qualifier.public static final int KEYBOARDHIDDEN_SOFT
public int keyboardHidden
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
.public static final int HARDKEYBOARDHIDDEN_UNDEFINED
hardKeyboardHidden
: a value indicating that no value has been set.public static final int HARDKEYBOARDHIDDEN_NO
hardKeyboardHidden
, value corresponding to the
physical keyboard being exposed.public static final int HARDKEYBOARDHIDDEN_YES
hardKeyboardHidden
, value corresponding to the
physical keyboard being hidden.public int hardKeyboardHidden
HARDKEYBOARDHIDDEN_NO
, HARDKEYBOARDHIDDEN_YES
.public static final int NAVIGATION_UNDEFINED
navigation
: a value indicating that no value has been set.public static final int NAVIGATION_NONAV
navigation
, value corresponding to the
nonav
resource qualifier.public static final int NAVIGATION_DPAD
navigation
, value corresponding to the
dpad
resource qualifier.public static final int NAVIGATION_TRACKBALL
navigation
, value corresponding to the
trackball
resource qualifier.public static final int NAVIGATION_WHEEL
navigation
, value corresponding to the
wheel
resource qualifier.public int navigation
NAVIGATION_NONAV
, NAVIGATION_DPAD
,
NAVIGATION_TRACKBALL
, NAVIGATION_WHEEL
.public static final int NAVIGATIONHIDDEN_UNDEFINED
navigationHidden
: a value indicating that no value has been set.public static final int NAVIGATIONHIDDEN_NO
navigationHidden
, value corresponding to the
navexposed
resource qualifier.public static final int NAVIGATIONHIDDEN_YES
navigationHidden
, value corresponding to the
navhidden
resource qualifier.public int navigationHidden
NAVIGATIONHIDDEN_NO
, NAVIGATIONHIDDEN_YES
.public static final int ORIENTATION_UNDEFINED
orientation
: a value indicating that no value has been set.public static final int ORIENTATION_PORTRAIT
orientation
, value corresponding to the
port
resource qualifier.public static final int ORIENTATION_LANDSCAPE
orientation
, value corresponding to the
land
resource qualifier.@Deprecated public static final int ORIENTATION_SQUARE
public int orientation
ORIENTATION_LANDSCAPE
, ORIENTATION_PORTRAIT
.public static final int UI_MODE_TYPE_MASK
uiMode
: bits that encode the mode type.public static final int UI_MODE_TYPE_UNDEFINED
uiMode
: a UI_MODE_TYPE_MASK
value indicating that no mode type has been set.public static final int UI_MODE_TYPE_NORMAL
uiMode
: a UI_MODE_TYPE_MASK
value that corresponds to
no
UI mode resource qualifier specified.public static final int UI_MODE_TYPE_DESK
public static final int UI_MODE_TYPE_CAR
public static final int UI_MODE_TYPE_TELEVISION
uiMode
: a UI_MODE_TYPE_MASK
value that corresponds to the
television
resource qualifier.public static final int UI_MODE_TYPE_APPLIANCE
uiMode
: a UI_MODE_TYPE_MASK
value that corresponds to the
appliance
resource qualifier.public static final int UI_MODE_TYPE_WATCH
public static final int UI_MODE_NIGHT_MASK
uiMode
: bits that encode the night mode.public static final int UI_MODE_NIGHT_UNDEFINED
uiMode
: a UI_MODE_NIGHT_MASK
value indicating that no mode type has been set.public static final int UI_MODE_NIGHT_NO
uiMode
: a UI_MODE_NIGHT_MASK
value that corresponds to the
notnight
resource qualifier.public static final int UI_MODE_NIGHT_YES
public int uiMode
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
.
public static final int SCREEN_WIDTH_DP_UNDEFINED
screenWidthDp
indicating that no width
has been specified.public int screenWidthDp
SCREEN_WIDTH_DP_UNDEFINED
if no width is specified.public static final int SCREEN_HEIGHT_DP_UNDEFINED
screenHeightDp
indicating that no width
has been specified.public int screenHeightDp
SCREEN_HEIGHT_DP_UNDEFINED
if no height is specified.public static final int SMALLEST_SCREEN_WIDTH_DP_UNDEFINED
smallestScreenWidthDp
indicating that no width
has been specified.public int smallestScreenWidthDp
SMALLEST_SCREEN_WIDTH_DP_UNDEFINED
if no width is specified.public static final int DENSITY_DPI_UNDEFINED
densityDpi
indicating that no width
has been specified.public static final int DENSITY_DPI_ANY
densityDpi
for resources that scale to any density (vector drawables).
public static final int DENSITY_DPI_NONE
densityDpi
for resources that are not meant to be scaled.
public int densityDpi
DENSITY_DPI_UNDEFINED
if no density is specified.public int compatScreenWidthDp
public int compatScreenHeightDp
public int compatSmallestScreenWidthDp
public int seq
public static final int NATIVE_CONFIG_MCC
public static final int NATIVE_CONFIG_MNC
public static final int NATIVE_CONFIG_LOCALE
public static final int NATIVE_CONFIG_TOUCHSCREEN
public static final int NATIVE_CONFIG_KEYBOARD
public static final int NATIVE_CONFIG_KEYBOARD_HIDDEN
public static final int NATIVE_CONFIG_NAVIGATION
public static final int NATIVE_CONFIG_ORIENTATION
public static final int NATIVE_CONFIG_DENSITY
public static final int NATIVE_CONFIG_SCREEN_SIZE
public static final int NATIVE_CONFIG_VERSION
public static final int NATIVE_CONFIG_SCREEN_LAYOUT
public static final int NATIVE_CONFIG_UI_MODE
public static final int NATIVE_CONFIG_SMALLEST_SCREEN_SIZE
public static final int NATIVE_CONFIG_LAYOUTDIR
public static final Parcelable.Creator<Configuration> CREATOR
public Configuration()
setToDefaults()
for this object to be valid. public Configuration(Configuration o)
public static int resetScreenLayout(int curLayout)
public static int reduceScreenLayout(int curLayout, int longSizeDp, int shortSizeDp)
public static String configurationDiffToString(int diff)
public boolean isLayoutSizeAtLeast(int size)
screenLayout
is at
least the given size.size
- The desired size, either SCREENLAYOUT_SIZE_SMALL
,
SCREENLAYOUT_SIZE_NORMAL
, SCREENLAYOUT_SIZE_LARGE
, or
SCREENLAYOUT_SIZE_XLARGE
.public void setTo(Configuration o)
public String toString()
Object
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())
public void setToDefaults()
@Deprecated public void makeDefault()
public int updateFrom(Configuration delta)
delta
are ignored and not copied in to the current Configuration.diff(android.content.res.Configuration)
public int diff(Configuration delta)
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
.public static boolean needNewResources(int configChanges, int interestingChanges)
updateFrom(Configuration)
.configChanges
- the mask of changes configurations as returned by
updateFrom(Configuration)
interestingChanges
- the configuration changes that the resource
can handle as given in
TypedValue.changingConfigurations
true
if the resource needs to be loaded, false
otherwisepublic boolean isOtherSeqNewer(Configuration other)
public int describeContents()
describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel dest, int flags)
Parcelable
writeToParcel
in interface Parcelable
dest
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.public void readFromParcel(Parcel source)
public int compareTo(Configuration that)
Comparable
The implementor must ensure sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception iff y.compareTo(x) throws an exception.)
The implementor must also ensure that the relation is transitive: (x.compareTo(y)>0 && y.compareTo(z)>0) implies x.compareTo(z)>0.
Finally, the implementor must ensure that x.compareTo(y)==0 implies that sgn(x.compareTo(z)) == sgn(y.compareTo(z)), for all z.
It is strongly recommended, but not strictly required that (x.compareTo(y)==0) == (x.equals(y)). Generally speaking, any class that implements the Comparable interface and violates this condition should clearly indicate this fact. The recommended language is "Note: this class has a natural ordering that is inconsistent with equals."
In the foregoing description, the notation sgn(expression) designates the mathematical signum function, which is defined to return one of -1, 0, or 1 according to whether the value of expression is negative, zero or positive.
compareTo
in interface Comparable<Configuration>
that
- the object to be compared.public boolean equals(Configuration that)
public boolean equals(Object that)
Object
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.
equals
in class Object
that
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.Object.hashCode()
,
HashMap
public int hashCode()
Object
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.
Object.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.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public LocaleList getLocales()
locale
, which would only provide the primary locale).public void setLocales(LocaleList locales)
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).locales
- The locale list. If null, an empty LocaleList will be assigned.public void setLocale(Locale loc)
.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)
.loc
- The locale. Can be null.public void clearLocales()
public int getLayoutDirection()
View.LAYOUT_DIRECTION_LTR
or
View.LAYOUT_DIRECTION_RTL
.View.LAYOUT_DIRECTION_RTL
if the configuration
is SCREENLAYOUT_LAYOUTDIR_RTL
, otherwise View.LAYOUT_DIRECTION_LTR
.public void setLayoutDirection(Locale loc)
loc
- The Locale. If null will set the layout direction to
View.LAYOUT_DIRECTION_LTR
. If not null will set it to the layout direction
corresponding to the Locale.View.LAYOUT_DIRECTION_LTR
,
View.LAYOUT_DIRECTION_RTL
public boolean isScreenRound()
public static String localesToResourceQualifier(LocaleList locs)
public static String resourceQualifierString(Configuration config)
public static Configuration generateDelta(Configuration base, Configuration change)
base
and change
. The
resulting delta can be used with updateFrom(Configuration)
.
Caveat: If the any of the Configuration's members becomes undefined, then
updateFrom(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.
public static void readXmlAttrs(XmlPullParser parser, Configuration configOut) throws XmlPullParserException, IOException
parser
- The Xml parser from which to read attributes.configOut
- The Configuration to populate from the Xml attributes.
XmlPullParserException
IOException
public static void writeXmlAttrs(XmlSerializer xml, Configuration config) throws IOException
xml
- The serializer to which to write the attributes.config
- The Configuration whose member fields to write.
IOException