From 0c82f6f64fa9a1a8fa29f9274459ecdaa658c8e2 Mon Sep 17 00:00:00 2001 From: Pasztor Tibor Viktor Date: Wed, 4 Jan 2017 11:03:07 +0100 Subject: [PATCH] LocalizationDelegate now uses Configuration.setLocale() on appropriate API levels. --- .../localizationactivity/LocalizationDelegate.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/localizationActivity/src/main/java/com/akexorcist/localizationactivity/LocalizationDelegate.java b/localizationActivity/src/main/java/com/akexorcist/localizationactivity/LocalizationDelegate.java index 88e5e3f..351a827 100644 --- a/localizationActivity/src/main/java/com/akexorcist/localizationactivity/LocalizationDelegate.java +++ b/localizationActivity/src/main/java/com/akexorcist/localizationactivity/LocalizationDelegate.java @@ -4,6 +4,8 @@ import android.content.Context; import android.content.Intent; import android.content.res.Configuration; +import android.os.Build.VERSION; +import android.os.Build.VERSION_CODES; import android.os.Bundle; import android.os.Handler; import android.util.DisplayMetrics; @@ -98,7 +100,11 @@ private void setupLocale(Locale locale) { private void updateLocaleConfiguration(Context context, Locale locale) { Configuration config = context.getResources().getConfiguration(); - config.locale = locale; + if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) { + config.setLocale(locale); + } else { + config.locale = locale; + } DisplayMetrics dm = context.getResources().getDisplayMetrics(); context.getResources().updateConfiguration(config, dm); }