Android Programming The Big Nerd Ranch Guide by Bill Phillips, Chris Stewart, Kristin Marsicano (z-lib.org)

(gtxtreme123) #1
Targeting a region

Testing custom locales


Different devices and different versions of Android know about and support different locales. It is
possible, then, that you may want to provide strings or other resources for a locale that is not available
on your test device. If this is the case, not to worry. You can use the Custom Locale tool on the
emulator to create and apply a locale that is not actually supported by the system image. The emulator
will then simulate a runtime configuration that includes that language/region combination, allowing
you to test how your app behaves in that configuration.


The emulator comes packaged with the Custom Locale tool. On your emulator, open the App Launcher
screen. Click on the icon labeled Custom Locale. Once launched, the Custom Locale tool allows you to
browse existing locales, add new custom locales, and apply a custom locale for testing (Figure 18.10).


Figure 18.10  Custom Locale tool


Note that if you apply a custom locale that is not supported by the system image, the system UI will
still display the default language. Your app, however, will resolve resources based on the custom locale
you chose.

Free download pdf