Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

LocalizationDelegate to use Configuration.setLocale() #10

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down