LocaleManagerCompat

Added in 1.9.0

public final class LocaleManagerCompat


Helper for accessing features in android.app.LocaleManager in a backwards compatible fashion.

Summary

Public methods

static @NonNull LocaleListCompat

Returns application locales for the calling app as a LocaleListCompat.

static @NonNull LocaleListCompat

Returns the current system locales, ignoring app-specific overrides.

Public methods

getApplicationLocales

Added in 1.11.0
@AnyThread
public static @NonNull LocaleListCompat getApplicationLocales(@NonNull Context context)

Returns application locales for the calling app as a LocaleListCompat. This API for non-androidx.appcompat.app.AppCompatDelegate context to easily get the per-app locale on the prior API 33 devices.

Returns a getEmptyLocaleList if no app-specific locales are set.

getSystemLocales

Added in 1.9.0
@AnyThread
public static @NonNull LocaleListCompat getSystemLocales(@NonNull Context context)

Returns the current system locales, ignoring app-specific overrides.

Note: Apps should generally access the user's locale preferences as indicated in their in-process android.os.LocaleLists. However, in case an app-specific locale is set, this method helps cater to rare use-cases which might require specifically knowing the system locale.