Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. Configuration conf = getResources().getConfiguration();
  2. conf.locale = new Locale("es") // Deprecated
  3. String language = conf.locale.getDisplayName() //Deprecated
  4.  
  5. Locale locale;
  6. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
  7. locale = context.getResources().getConfiguration().getLocales().get(0);
  8. } else {
  9. locale = context.getResources().getConfiguration().locale;
  10. }
  11.  
  12. Configuration conf = getResources().getConfiguration();
  13. conf.setLocale = new Locale("es") // VERSION_CODES.JELLY_BEAN_MR1+
  14. String language = conf.getLocales().get(0).toString() // VERSION_CODES.N+
  15.  
  16. Configuration config = context.getResources().getConfiguration();
  17.  
  18. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
  19. locale = getSystemLocale(config);
  20. } else {
  21. locale = getSystemLocaleLegacy(config);
  22. }
  23.  
  24. Locale locale = new Locale("es");
  25. Locale.setDefault(locale);
  26.  
  27. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
  28. setSystemLocale(config, locale);
  29. } else {
  30. setSystemLocaleLegacy(config, locale);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement