Stay organized with collections Save and categorize content based on your preferences.

LocaleConfig

public class LocaleConfig
extends Object

java.lang.Object
   ↳ android.app.LocaleConfig


The LocaleConfig of an application. Defined in an XML resource file with an <locale-config> element and referenced in the manifest via android:localeConfig on <application>.

For more information, see the section on per-app language preferences.

Summary

XML attributes

android:localeConfig An XML resource with the application's 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 The IETF BCP47 language tag of the supported locale. 

Constants

int STATUS_NOT_SPECIFIED

No android:localeConfig tag on .

int STATUS_PARSING_FAILED

Malformed input in the XML file where the LocaleConfig was stored.

int STATUS_SUCCESS

succeeded reading the LocaleConfig structure stored in an XML file.

String TAG_LOCALE

String TAG_LOCALE_CONFIG

Public constructors

LocaleConfig(Context context)

Returns the LocaleConfig for the provided application context

Public methods

int getStatus()

Get the status of reading the resource file where the LocaleConfig was stored.

LocaleList getSupportedLocales()

Returns the locales supported by the specified application.

Inherited methods

XML attributes

android:localeConfig

An XML resource with the application's 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

The IETF BCP47 language tag of the supported locale. LocaleConfig

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

Constants

STATUS_NOT_SPECIFIED

Added in API level 33
public static final int STATUS_NOT_SPECIFIED

No android:localeConfig tag on .

Constant Value: 1 (0x00000001)

STATUS_PARSING_FAILED

Added in API level 33
public static final int STATUS_PARSING_FAILED

Malformed input in the XML file where the LocaleConfig was stored.

Constant Value: 2 (0x00000002)

STATUS_SUCCESS

Added in API level 33
public static final int STATUS_SUCCESS

succeeded reading the LocaleConfig structure stored in an XML file.

Constant Value: 0 (0x00000000)

TAG_LOCALE

Added in API level 33
public static final String TAG_LOCALE

Constant Value: "locale"

TAG_LOCALE_CONFIG

Added in API level 33
public static final String TAG_LOCALE_CONFIG

Constant Value: "locale-config"

Public constructors

LocaleConfig

Added in API level 33
public LocaleConfig (Context context)

Returns the LocaleConfig for the provided application context

Parameters
context Context: the context of the application This value cannot be null.

Public methods

getStatus

Added in API level 33
public int getStatus ()

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.

Returns
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 STATUS_SUCCESS, STATUS_NOT_SPECIFIED, or STATUS_PARSING_FAILED

getSupportedLocales

Added in API level 33
public LocaleList getSupportedLocales ()

Returns the locales supported by the specified application.

Note: The locale format should follow the IETF BCP47 regular expression

Returns
LocaleList the LocaleList This value may be null.