Per-app language preferences - get list of app's available language programmatically?

28 views Asked by At

So based on https://developer.android.com/guide/topics/resources/app-languages#kotlin

we can use

android {
  androidResources {
    generateLocaleConfig = true
  }
}

which automatically generates language list available for for users to change for a specific app:

enter image description here

(all languages list)

This list available for Android 13+ and only in app's system settings.

I want to implement a picker inside the app.

How can I get the same languages list without manually implementing it?

How to access the list which android.androidResources.generateLocaleConfig feature generated?

Update

I tried

val localeManager = context
    .getSystemService(LocaleManager::class.java)
localeManager.overrideLocaleConfig?.supportedLocales?.let { localeList ->
    Timber.d("localeList ${localeList.size()}")
}

but it's empty and works only for Android 13+

LocaleManagerCompat doesn't have such method

0

There are 0 answers