| | |
| | | String language = UserConfigManage.getInstance().getCurrentAppLanguage(); |
| | | if (TextUtils.isEmpty(language)) { |
| | | //从内存里面获取不到语言,获取当前系统的; |
| | | String str = getResources().getConfiguration().locale.getCountry(); |
| | | if (str.equals("CN") || str.equals("TW")) { |
| | | String str = getResources().getConfiguration().locale.getLanguage(); |
| | | if (str.equals(LocalManageUtil.zh)) { |
| | | UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.zh); |
| | | } else { |
| | | UserConfigManage.getInstance().setCurrentAppLanguage(LocalManageUtil.en); |
| | |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 初始化uni app mqtt |
| | | */ |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | protected void attachBaseContext(Context base) { |
| | | MultiDex.install(base); |
| | |
| | | /** |
| | | * 支持中英文切换 |
| | | */ |
| | | public Context getAppLocaleContext(Context context) { |
| | | try { |
| | | Locale locale = new Locale(UserConfigManage.getInstance().getCurrentAppLanguage()); |
| | | Configuration configuration = context.getResources().getConfiguration(); |
| | | configuration.setLocale(locale); |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| | | configuration.setLocales(new LocaleList(locale)); |
| | | } |
| | | return context.createConfigurationContext(configuration); |
| | | } catch (Exception e) { |
| | | return context; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 支持中英文切换 |
| | | */ |
| | | public Context getAppLocaleContext() { |
| | | try { |
| | | Locale locale = new Locale(UserConfigManage.getInstance().getCurrentAppLanguage()); |