Ich ändere das Anwendungsgebietsschema basierend auf der Benutzerauswahl. Unabhängig vom Geräte-Gebietsschema.So rufen Sie das Gebietsschema des Geräts ab, nachdem Sie das Gebietsschema für die Anwendung geändert haben
public void setDefaultLocale(Context context, String locale) {
Locale appLoc = new Locale(locale);
Locale.setDefault(appLoc);
Configuration appConfig = new Configuration();
appConfig.locale = appLoc;
context.getResources().updateConfiguration(appConfig,
context.getResources().getDisplayMetrics());
}
Aber ich möchte mit wissen, was das Gerät auch locale sein wird.
Wenn ich versuche, bekomme ich immer das Gebietsschema, das ich auf Anwendung eingestellt habe.
ex: applictaion ist in ENGLISH und Gerät ist in CHINESE. Ich bekomme immer Englisch.
für immer locale verwenden,
Option 1.
String locale = context.getResources().getConfiguration().locale.getCountry();
Option 2.
String local_country = ((Activity) context).getBaseContext().getResources().getConfiguration().locale.getCountry();
Jede Hilfe sehr geschätzt wird !!!
Ähnliche: http://stackoverflow.com/questions/23348954/android-get-device-locale – trante