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 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();
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
android.os.Parcelable
|
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CREATOR | |||||||||||
fontScale | Current user preference for the scaling factor for fonts, relative to the base density scaling. | ||||||||||
hardKeyboardHidden | A flag indicating whether the hard keyboard has been hidden. | ||||||||||
keyboard | The kind of keyboard attached to the device. | ||||||||||
keyboardHidden | A flag indicating whether any keyboard is available. | ||||||||||
locale | Current user preference for the locale. | ||||||||||
mcc | IMSI MCC (Mobile Country Code). | ||||||||||
mnc | IMSI MNC (Mobile Network Code). | ||||||||||
navigation | The kind of navigation method available on the device. | ||||||||||
navigationHidden | A flag indicating whether any 5-way or DPAD navigation available. | ||||||||||
orientation | Overall orientation of the screen. | ||||||||||
screenHeightDp | The current height of the available screen space, in dp units. | ||||||||||
screenLayout | Bit mask of overall layout of the screen. | ||||||||||
screenWidthDp | The current width of the available screen space, in dp units. | ||||||||||
smallestScreenWidthDp | The smallest screen size an application will see in normal operation. | ||||||||||
touchscreen | The kind of touch screen attached to the device. | ||||||||||
uiMode | Bit mask of the ui mode. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Construct an invalid Configuration. You must call
setToDefaults()
for this object to be valid. | |||||||||||
Makes a deep copy suitable for modification.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Parcelable methods
| |||||||||||
Return a bit mask of the differences between this Configuration
object and the given one.
| |||||||||||
Compares this instance with the specified object and indicates if they
are equal.
| |||||||||||
Returns an integer hash code for this object.
| |||||||||||
Check if the Configuration's current
screenLayout is at
least the given size. | |||||||||||
Determine if a new resource needs to be loaded from the bit set of
configuration changes returned by
updateFrom(Configuration) . | |||||||||||
Set this object to the system defaults.
| |||||||||||
Returns a string containing a concise, human-readable description of this
object.
| |||||||||||
Copy the fields from delta into this Configuration object, keeping
track of which ones have changed.
| |||||||||||
Flatten this object in to a Parcel.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
android.os.Parcelable
| |||||||||||
From interface
java.lang.Comparable
|
Constant for screenLayout
: a SCREENLAYOUT_SIZE_MASK
value indicating the screen is at least approximately 480x640 dp units.
See Supporting
Multiple Screens for more information.
Constant for screenLayout
: bits that encode the size.
Constant for screenLayout
: a SCREENLAYOUT_SIZE_MASK
value indicating the screen is at least approximately 320x470 dp units.
See Supporting
Multiple Screens for more information.
Constant for screenLayout
: a SCREENLAYOUT_SIZE_MASK
value indicating the screen is at least approximately 320x426 dp units.
See Supporting
Multiple Screens for more information.
Constant for screenLayout
: a SCREENLAYOUT_SIZE_MASK
value indicating that no size has been set.
Constant for screenLayout
: a SCREENLAYOUT_SIZE_MASK
value indicating the screen is at least approximately 720x960 dp units.
See Supporting
Multiple Screens for more information.
Current user preference for the scaling factor for fonts, relative to the base density scaling.
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
.
The kind of keyboard attached to the device.
One of: KEYBOARD_NOKEYS
, KEYBOARD_QWERTY
,
KEYBOARD_12KEY
.
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
.
The kind of navigation method available on the device.
One of: NAVIGATION_NONAV
, NAVIGATION_DPAD
,
NAVIGATION_TRACKBALL
, NAVIGATION_WHEEL
.
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
.
Overall orientation of the screen. May be one of
ORIENTATION_LANDSCAPE
, ORIENTATION_PORTRAIT
,
or ORIENTATION_SQUARE
.
The current height of the available screen space, in dp units.
Bit mask of overall layout of the screen. Currently there are two 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
.
See Supporting Multiple Screens for more information.
The current width of the available screen space, in dp units.
The smallest screen size an application will see in normal operation. This is the smallest value of both screenWidthDp and screenHeightDp in both portrait and landscape.
The kind of touch screen attached to the device.
One of: TOUCHSCREEN_NOTOUCH
, TOUCHSCREEN_STYLUS
,
TOUCHSCREEN_FINGER
.
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
,
or UI_MODE_TYPE_CAR
.
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
.
Construct an invalid Configuration. You must call setToDefaults()
for this object to be valid.
Makes a deep copy suitable for modification.
Parcelable methods
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.
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
.
Compares this instance with the specified object and indicates if they
are equal. In order to be equal, o
must 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 true
only if this ==
o
. See Writing a correct
equals
method
if you intend implementing your own equals
method.
The general contract for the equals
and hashCode()
methods is that if equals
returns true
for
any two objects, then hashCode()
must return the same value for
these objects. This means that subclasses of Object
usually
override either both methods or neither of them.
that | the object to compare this instance with. |
---|
true
if the specified object is equal to this Object
; false
otherwise.Returns an integer hash code for this object. By contract, any two
objects for which equals(Object)
returns true
must return
the same hash code value. This means that subclasses of Object
usually 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
hashCode
method
if you intend implementing your own hashCode
method.
Check if the Configuration's current 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 . |
---|
Determine if a new resource needs to be loaded from the bit set of
configuration changes returned by updateFrom(Configuration)
.
configChanges | The mask of changes configurations as returned by
updateFrom(Configuration) . |
---|---|
interestingChanges | The configuration changes that the resource
can handled, as given in changingConfigurations . |
Returns 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
toString
method
if you intend implementing your own toString
method.
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.
diff(Configuration)
.
Flatten this object in to a Parcel.
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_WRITE_RETURN_VALUE .
|