0

Is there any difference or are they same (except the format they return) ?

apangin
  • 92,924
  • 10
  • 193
  • 247

2 Answers2

1

After a quick Google, I've found this: http://androiddevevelopmentnotes.blogspot.com/2011/08/how-to-find-available-locales-in-andoid.html

Locale.getAvailableLocales() - returns a pretty large number of Locales.

Activity.getAssets().getLocales() - returns the Locales that the AssetManager contains data for, which is typically a lot less than what Locale.getAvailableLocales() returns.

1

From the doc:

getAvailableLocales

Returns an array of all installed locales. The returned array represents the union of locales supported by the Java runtime environment and by installed LocaleServiceProvider implementations. It must contain at least a Locale instance equal to Locale.US.

and

getLocales

Get the locales that this asset manager contains data for.

So the first is returning all locales available on the system and the second one is returning locales "backed by assets"

  • see also https://stackoverflow.com/questions/11611065/get-the-applications-resources-languages/11751526#11751526 –  Jan 27 '17 at 12:05