7

I am trying to implement the per app language feature that was introduced in Android 13. I am using AppCompatDelegate.setApplicationLocales and it's working very well on Android 13. On Android 12 it's working if I use activity context but not application context. The following snippet from an activity produces different output on Android 12.

Log.d(TAG, applicationContext.getString(R.string.settings_change_button))
Log.d(TAG, getString(R.string.settings_change_button))

First line is printed in phone language and second in line is printed in app language. I added the AppLocalesMetadataHolderService as it is shown here https://developer.android.com/guide/topics/resources/app-languages#android12-impl

Should I do something else to get the application context to use the app language?

1 Answers1

7

Unfortunately this seems to be the intended behavior which renders this feature to be useless for me. https://issuetracker.google.com/issues/243457462#comment2

  • And they dont mention it in official docs ? ... thats why I wasted time on this ... – Renetik May 06 '23 at 13:14
  • 1
    It has now been included in the official docs and support for non-Activity context has been added in the 1.7.0-alpha03 release https://developer.android.com/jetpack/androidx/releases/appcompat#1.7.0-alpha03 – Subhrajyoti Sen Jul 27 '23 at 08:04