Changing the Android emulator locale automatically

前端 未结 3 2131
情话喂你
情话喂你 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:49

    Personally I think the simplest way is to start the emulator, probably a clean instance unless you are running integration tests that depends on other applications and then change locale using adb:

    $ adb shell '
    setprop persist.sys.language en;
    setprop persist.sys.country GB;
    stop;
    sleep 5;
    start'
    

    or whatever locale you want to set. To verify that your change was successful just use

    $ adb shell 'getprop persist.sys.language'
    

    You may also want to run emulators on know ports, check my answer in this thread.


    Note that you can also set system properties directly when starting the emulator:

    emulator -avd my_avd -prop persist.sys.language=en -prop persist.sys.country=GB
    

    This way, you can create a plain old emulator of any type then start it up immediately using the locale of your choice, without first having to make any modifications to the emulator images.

    This locale will persist for future runs of the emulator, though of course you can always change it again at startup or during runtime.

提交回复
热议问题