how could i detect if my phone language has been changed, like facebook application that will give us announce : please wait, we preparing your language
i used myString = Locale.getDefault().getDisplayLanguage();
in my onCreate()
on my onCreate()
@Override
public void onCreate(Bundle savedInstanceState) {
String myString = Locale.getDefault().getDisplayLanguage();
if(myString.equals("en"){
ProgressDialog progressDialog = new ProgressDialog(getApplicationContext());
progressDialog.setMessage("Please wait, we preparing your language");
progressDialog.show();
/*
it will dismiss until the language has been prepared
*/
}else{
//do nothing
}
}
}
please give me suggestion, i still learning, will try harder. thank you.
You can use: ACTION_LOCALE_CHANGED
Here an example:
private BroadcastReceiver mLangReceiver = null;
protected BroadcastReceiver setupLangReceiver(){
if(mLangReceiver == null) {
mLangReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// do what you want
}
};
IntentFilter filter = new IntentFilter(Intent.ACTION_LOCALE_CHANGED);
registerReceiver(mLangReceiver, filter);
}
return mLangReceiver;
}
What about to make a broadcast listener to: ACTION_LOCALE_CHANGED
Since "Locale represents a language/country/variant combination. Locales are used to alter the presentation of information such as numbers or dates to suit the conventions in the region they describe."
http://developer.android.com/reference/java/util/Locale.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With