ChangeLanguageExample icon indicating copy to clipboard operation
ChangeLanguageExample copied to clipboard

Actionbar language stays to default language on Android Nougat

Open antonio-ivanovski opened this issue 8 years ago • 2 comments

I have changed the locale with call to onAttach(context) on my Application and on my base AppCompatActivity that every other Activity extends.

On Android API < 24 (Kitkat, Lollipop, Marshmallow) it works great.

On Android 24 and 25 the content of the whole activity is on the desired language. Unfortunately the language of the actionbar is on the device preferred language.

I have debugged a bit and this methods are called from the system: Activity.onPostCreate -> Activity.onTitleChanged(getTitle(), getTitleColor())

Here Activity.getTitle() returns Activity.mTitle which is the title on the prefered system language.

Only (bad)workaround i found is store the string id for the activity, and call Activity.setTitle(StringResId) on onCreate

antonio-ivanovski avatar Mar 02 '17 13:03 antonio-ivanovski

Had exactly the same problem. However, I don't think it is a bad workaround because it is just an alternative way of setting the title (instead of setting it in AndroidManifest.xml).

felixwiemuth avatar Sep 20 '17 20:09 felixwiemuth

@toteto Isn't that what the code has? https://github.com/gunhansancar/ChangeLanguageExample/blob/master/app/src/main/java/com/gunhansancar/changelanguageexample/MainActivity.java#L34

veerenmandalia avatar Nov 17 '17 03:11 veerenmandalia