①:在baseActivity里面重写attachBaseContext方法,各个子activity继承base
@Override
protected void attachBaseContext(Context newBase) {
Configuration configuration = newBase.getResources().getConfiguration();
configuration.setLocale(Locale.ENGLISH);
Context createContext = newBase.createConfigurationContext(configuration);
super.attachBaseContext(createContext);
}
②:设置完保存完语言信息后,重启到首页
Intent intent = new Intent(this, HomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
getActivity().startActivity(intent);