Created
July 15, 2015 06:50
-
-
Save logcat/d922f64b8f61990a25db to your computer and use it in GitHub Desktop.
Android activity role to change and test different locales
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static final Locale FRENCH_LOCALE = new Locale("fr", "FR"); | |
@Rule | |
public ActivityTestRule<SplashScreenActivity> activityRule = new ActivityTestRule(SplashScreenActivity.class, true, true) { | |
@Override | |
protected void beforeActivityLaunched() { | |
super.beforeActivityLaunched(); | |
Locale.setDefault(FRENCH_LOCALE); | |
Resources res = getInstrumentation().getTargetContext().getResources(); | |
Configuration configuration = new Configuration(); | |
configuration.locale = FRENCH_LOCALE; | |
res.updateConfiguration(configuration, res.getDisplayMetrics()); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment