LocaleConfig
open class LocaleConfig : Parcelable
kotlin.Any | |
↳ | android.app.LocaleConfig |
The LocaleConfig of an application. There are two sources. One is from an XML resource file with an <locale-config>
element and referenced in the manifest via android:localeConfig
on <application>
. The other is that the application dynamically provides an override version which is persisted in LocaleManager.setOverrideLocaleConfig(LocaleConfig)
.
For more information about the LocaleConfig from an XML resource file, see the section on per-app language preferences.
Summary
XML attributes | |
---|---|
android:localeConfig |
An XML resource with the application's android. |
android:name |
The IETF BCP47 language tag of the supported locale. |
Constants | |
---|---|
static Int |
No android:localeConfig tag on . |
static Int |
Malformed input in the XML file where the LocaleConfig was stored. |
static Int |
succeeded reading the LocaleConfig structure stored in an XML file. |
static String | |
static String |
Inherited constants | |
---|---|
Public constructors | |
---|---|
LocaleConfig(context: Context) Returns an override LocaleConfig if it has been set via |
|
LocaleConfig(locales: LocaleList) Return the LocaleConfig with any sequence of locales combined into a |
Public methods | |
---|---|
open Int | |
open static LocaleConfig |
fromContextIgnoringOverride(context: Context) Returns a LocaleConfig from the application resources regardless of whether any LocaleConfig is overridden via |
open Locale? |
Returns the locale the strings in values/strings. |
open Int |
Get the status of reading the resource file where the LocaleConfig was stored. |
open LocaleList? |
Returns the locales supported by the specified application. |
open Unit |
writeToParcel(dest: Parcel, flags: Int) Flatten this object in to a Parcel. |
Properties | |
---|---|
static Parcelable.Creator<LocaleConfig!> |
XML attributes
android:localeConfig
android:localeConfig
android.app.LocaleConfig
May be a reference to another resource, in the form "@[+][package:]type/name
" or a theme attribute in the form "?[package:]type/name
".
android:name
android:name
android.app.LocaleConfig
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;
Constants
STATUS_NOT_SPECIFIED
static val STATUS_NOT_SPECIFIED: Int
No android:localeConfig tag on .
Value: 1
STATUS_PARSING_FAILED
static val STATUS_PARSING_FAILED: Int
Malformed input in the XML file where the LocaleConfig was stored.
Value: 2
STATUS_SUCCESS
static val STATUS_SUCCESS: Int
succeeded reading the LocaleConfig structure stored in an XML file.
Value: 0
Public constructors
LocaleConfig
LocaleConfig(context: Context)
Returns an override LocaleConfig if it has been set via LocaleManager.setOverrideLocaleConfig(LocaleConfig)
. Otherwise, returns the LocaleConfig from the application resources.
Parameters | |
---|---|
context |
Context: the context of the application. This value cannot be null . |
LocaleConfig
LocaleConfig(locales: LocaleList)
Return the LocaleConfig with any sequence of locales combined into a LocaleList
.
Note: Applications seeking to create an override LocaleConfig via LocaleManager.setOverrideLocaleConfig(LocaleConfig)
should use this constructor to first create the LocaleConfig they intend the system to see as the override.
Note: The creation of this LocaleConfig does not automatically mean it will become the override config for an application. Any LocaleConfig desired to be the override must be passed into the LocaleManager.setOverrideLocaleConfig(LocaleConfig)
, otherwise it will not persist or affect the system's understanding of app-supported resources.
Parameters | |
---|---|
locales |
LocaleList: the desired locales for a specified application This value cannot be null . |
Public methods
describeContents
open fun describeContents(): Int
Return | |
---|---|
Int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR |
fromContextIgnoringOverride
open static fun fromContextIgnoringOverride(context: Context): LocaleConfig
Returns a LocaleConfig from the application resources regardless of whether any LocaleConfig is overridden via LocaleManager.setOverrideLocaleConfig(LocaleConfig)
.
Parameters | |
---|---|
context |
Context: the context of the application. This value cannot be null . |
Return | |
---|---|
LocaleConfig |
This value cannot be null . |
getDefaultLocale
open fun getDefaultLocale(): Locale?
Returns the locale the strings in values/strings.xml (the default strings in the directory with no locale qualifier) are in if specified, otherwise null
Return | |
---|---|
Locale? |
The default Locale or null |
getStatus
open fun getStatus(): Int
Get the status of reading the resource file where the LocaleConfig was stored.
Distinguish "the application didn't provide the resource file" from "the application provided malformed input" if getSupportedLocales()
returns null
.
Return | |
---|---|
Int |
STATUS_SUCCESS if the LocaleConfig structure existed in an XML file was successfully read, or STATUS_NOT_SPECIFIED if no android:localeConfig tag on pointing to an XML file that stores the LocaleConfig, or STATUS_PARSING_FAILED if the application provided malformed input for the LocaleConfig structure. Value is android.app.LocaleConfig#STATUS_SUCCESS , android.app.LocaleConfig#STATUS_NOT_SPECIFIED , or android.app.LocaleConfig#STATUS_PARSING_FAILED |
getSupportedLocales
open fun getSupportedLocales(): LocaleList?
Returns the locales supported by the specified application.
Note: The locale format should follow the IETF BCP47 regular expression
Return | |
---|---|
LocaleList? |
the LocaleList This value may be null . |
writeToParcel
open fun writeToParcel(
dest: Parcel,
flags: Int
): Unit
Flatten this object in to a Parcel.
Parameters | |
---|---|
dest |
Parcel: This value cannot be null . |
flags |
Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE . Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |