我如何检测我的电话语言是否已更改,例如可以通知我们的facebook应用程序: please wait, we preparing your language
我用myString = Locale.getDefault().getDisplayLanguage();
在我的onCreate()
在我的 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 } } }
请给我建议,我仍在学习,会努力的。谢谢。
您可以使用:ACTION_LOCALE_CHANGED
这里是一个例子:
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; }