Home » Android » localization – How to get notified when system locale changes in Android?

localization – How to get notified when system locale changes in Android?

Posted by: admin June 15, 2020 Leave a comment

Questions:

I’m regularly passing phone’s locale as part of URL to the server.

private static String getLocaleStr() {
     Locale locale = Locale.getDefault();
     return locale.getLanguage() + locale.getCountry();
}

I don’t want to recall getLocalStr() every time I generate a URL. Is there a way to get notified when system locale changes?

How to&Answers:

An Intent is broadcast for this:

http://developer.android.com/reference/android/content/Intent.html#ACTION_LOCALE_CHANGED