Skip to content

Instantly share code, notes, and snippets.

View Jasonlhy's full-sized avatar
:octocat:

Jason Liu Jasonlhy

:octocat:
View GitHub Profile

Test

@Jasonlhy
Jasonlhy / LocaleManager.java
Last active June 26, 2021 20:54
LocaleManager for handling android language switch at runtime
public class LocaleManager {
private static final String LANGUAGE_KEY = "CHOOSE_LANGUAGE";
public static Context setLocale(Context c) {
String savedLanguage = getLanguage(c);
return savedLanguage == null ? c : updateResources(c, savedLanguage);
}
public static Context setNewLocale(Context c, String language) {
persistLanguage(c, language);