Changing the Android emulator locale automatically

前端 未结 3 2127
情话喂你
情话喂你 2020-12-04 10:26

For automated testing (using Hudson) I have a script that generates a bunch of emulators for many combinations of Android OS version, screen resolution, screen density and l

3条回答
  •  旧巷少年郎
    2020-12-04 10:40

    Accepted answer doesn't work anymore. persist.sys.language and persist.sys.country are gone from emulator properties.

    My solution is to use preinstalled on android emulator "Custom locale" application. Simply send intent with extra language parameter to it as below:

    adb shell am broadcast -a com.android.intent.action.SET_LOCALE --es com.android.intent.extra.LOCALE EN
    

    More information here - prepare android emulator for UI test automation.

    UPDATE: based on comment from Jonas Alves the following command works on API 28+:

    adb shell am broadcast -a com.android.intent.action.SET_LOCALE --es com.android.intent.extra.LOCALE "en_US" com.android.customlocale2
    

提交回复
热议问题