LocaleManagerCompat
public final class LocaleManagerCompat
Helper for accessing features in android.app.LocaleManager in a backwards compatible fashion.
Summary
Public methods |
|
|---|---|
static @NonNull LocaleListCompat |
@AnyThreadReturns application locales for the calling app as a |
static @NonNull LocaleListCompat |
@AnyThreadReturns the current system locales, ignoring app-specific overrides. |
Public methods
getApplicationLocales
@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
@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.