Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- OnCreate()
- {
- ... ...
- Configuration config = getBaseContext().getResources().getConfiguration();
- config.locale = Locale.FRANCE; // set locale to french
- getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
- setContentView(R.layout.main);
- }
- { ... ...
- Configuration config = getBaseContext().getResources().getConfiguration();
- config.locale = Locale.ITALY; // change locale to Italian
- getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
- }
- {
- Intent intent = getIntent();
- finish();
- startActivity(intent);
- }
- String lang = getSharedPreferences(PREFS_APP, 0).getString(LANGUAGE, Locale.getDefault().getLanguage());
- locale = new Locale(lang);
- if (locale != null) {
- newConfig.locale = locale;
- Locale.setDefault(locale);
- getBaseContext().getResources().updateConfiguration(newConfig, getBaseContext().getResources().getDisplayMetrics());
- }
- Configuration c = new Configuration();
- Locale newLocale = new Locale(localeCode);
- Locale.setDefault(newLocale);
- c.locale = newLocale;
- ctx.getResources().updateConfiguration(c, ctx.getResources().getDisplayMetrics());
- Intent goTo = new Intent(ctx, MainActivity.class);
- goTo.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- act.startActivity(goTo);
Add Comment
Please, Sign In to add comment