简体   繁体   中英

Will android application get message about system locale changes?

In JNI method I use call to Java objects to get locale settings.

My JNI call is similar to Locale.getDefault() that I used to get it.

Will application be notified about system locale changes?

So, typical usecase:

  1. Run my application.
  2. In native code get locale from Locale.getDefault();
  3. Change current system locale by settings menu on device.
  4. In native code get locale from Locale.getDefault();

Will I get actual information about current locale in step 4?

An Intent is broadcast for this the ACTION_LOCALE_CHANGED should let you know when a change in the preferences has happened. However if you're calling it after its changed without having been notified, you'll still get the new locale information.

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

Will I get actual information about current locale in step 4?

Yes, I will.

But there is one issue:

If main activity blocked by native call , locale information will not change till the main activity not recive ACTION_LOCALE_CHANGED.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM