Configuration Management for Android

Developers must try to support the widest possible range of devices, without biting off more than they can chew in terms of maintenance and configuration management. The following are some factors to consider when determining target platforms:

► What hardware features will the application require? Does the application require a touch screen? A hardware keyboard? A directional pad? Specific screen dimensions?

► What software features will the application require? Does the application support different screen orientations?

What Android SDK does the application require?

While some of these decisions necessitate changes in the project libraries and the Android manifest file, many can be handled using the same resource directory qualifier strategy used for application internationalization.

Resource directories can be qualified to provide resources for a number of different application configurations (see Table 20.1). You can apply these directory name qualifiers to the resource subdirectories, such as / res/values/. Qualifiers are concatenated onto the existing subdirectory name, in a strict order, shown in precedence order in Table 20.1. You can combine multiple qualifiers by separating them with dashes. Qualifiers are always lowercase, and a directory can contain only one qualifier of each type. Custom qualifiers are not allowed.

TABLE 20.1 Important Resource Directory Qualifiers Directory Qualifier Type Values Comments

Language en, fr, es, zh, ISO 639-1 two-letter ja, ko, de, and so on language codes

Region/locale rUS, rGB, rFR, rJP, rDE, and so on

ISO 3166-1-alpha-2 region code in ALL UPPERCASE, preceded by a lowercase r Screen size and density ratio

Portrait mode, landscape mode

Screen density that the resource is for

No Touch screen, Stylus-only, Finger Touch screen

Keyboard available, Keyboard not available to user, resources used only with software keyboard

Whether navigational keys are available or hidden because phone keypad is shut

Screen dimensions small, normal, large port, land

Screen orientation

Screen pixel density ldpi, mdpi, hdpi, nodpi notouch, stylus, finger

Touch screen type

Is keyboard available keysexposed, keyshidden, keyssoft

Are navigation keys available navexposed, navhidden

Directory Qualifier Type Values Comments

Primary non-touch screen

nonav, dpad,

Four-key directional pad,

navigation method

trackball, wheel

trackball, scroll wheel

SDK version

v1, v2, v3, v4,

The SDK version's API

v5, v6, v7,

level (for example, v1 is

and so on

Android SDK 1.0, while

v7 represents Android

SDK 2.1)

You can concatenate together resource directories by using dashes. Here are some good examples of properly qualified directories:

/res/values-en-rUS-port-finger

/res/drawables-en-rUS-land

/res/values-en-qwerty

The following are some incorrectly qualified directories:

/res/values-en-rUS-rGB

/res/values-en-rUS-port-FINGER

/res/values-en-rUS-port-finger-custom

For an exhaustive list of the qualifiers available for resource customization (mobile country code, carrier, screen size, and so on), see the Android developer website: http://developer.android.com/guide/topics/resources/resources-i18n.html#AlternateResources.

0 0

Post a comment