Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android change language listener

Language can be changed in

Home > Menu > Settings > Locale & text > Select locale

I am wondering how can I detect such change? My application is seems to be turned off by system during such operation, however I have to be 100% sure, that this is official rule.

Do you know something about this?

like image 474
noisy Avatar asked Apr 21 '11 09:04

noisy


2 Answers

An Intent is broadcast for this:

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

You can register a BroadcastReceiver in your manifest to handle it.

like image 84
Christopher Perry Avatar answered Nov 15 '22 16:11

Christopher Perry


http://developer.android.com/guide/topics/manifest/activity-element.html#config says:

android:configChanges Lists configuration changes that the activity will handle itself. When a configuration change occurs at runtime, the activity is shut down and restarted by default, but declaring a configuration with this attribute will prevent the activity from being restarted. Instead, the activity remains running and its onConfigurationChanged() method is called.

Note: Using this attribute should be avoided and used only as a last-resort. Please read Handling Runtime Changes for more information about how to properly handle a restart due to a configuration change.

Any or all of the following strings are valid values for this attribute. Multiple values are separated by '|' — for example, "locale|navigation|orientation".

like image 22
noisy Avatar answered Nov 15 '22 16:11

noisy