A Flavor specifies a set of configuration values, grouped as a preset. Typically, the user can choose from these Flavors in the companion app.
A Flavor can include values for existing configurations, including the
following types:
BooleanConfigurationColorConfigurationListConfigurationComplicationSlot
Since version 2
Syntax
<Flavor id="string" displayName="string" screenReaderText="string"> <!-- Flavor-specific child elements. --> <Configuration ... /> <ComplicationSlot .../> </Flavor>
You can include Flavor elements within a UserConfigurations element,
as shown in the following example:
<UserConfigurations>
<!-- Configuration definitions go here -->
<ColorConfiguration id="themeColor" ... />
<!-- ... -->
<!-- The defaultValue is required. Set this attribute to the ID
of the flavor that the system should show by default. -->
<Flavors defaultValue="1">
<Flavor id="1" displayName="1st flavor">
<Configuration id="themeColor" optionId="0"/>
<ComplicationSlot slotId="0">
<DefaultProviderPolicy
defaultSystemProvider="DAY_OF_WEEK"
defaultSystemProviderType="SHORT_TEXT"/>
</ComplicationSlot>
</Flavor>
<Flavor id="2" displayName="2nd flavor">
<Configuration id="themeColor" optionId="1"/>
<ComplicationSlot slotId="0">
<DefaultProviderPolicy
defaultSystemProvider="WATCH_BATTERY"
defaultSystemProviderType="SHORT_TEXT"/>
</ComplicationSlot>
</Flavor>
</Flavors>
</UserConfigurations>
In order to use Flavors, the following must be added to
res/xml/watch_face_info.xml:
<?xml version="1.0" encoding="utf-8"?>
<WatchFaceInfo>
...
<MultipleInstancesAllowed value="true" />
<FlavorsSupported value="true" />
</WatchFaceInfo>
Attributes
The Flavor element has the following attributes:
Required attributes
The following attributes are required:
id- A unique identifier for the
Flavor. displayName- A string that is displayed in the companion. This can be a literal string
or a reference to a string resource such as
@string/my_flavor_name.
Optional attributes
The following attributes are optional:
icon- Deprecated. The icon is no longer shown in the companion. A preview image is instead generated based on the flavor configuration
screenReaderText- A string that is used if the user has TalkBack enabled. This can be a
literal string or a reference to a string resource such as
@string/my_flavor_screen_reader_text.
Inner elements
The Flavor element must contain at least one Configuration element and can
optionally include ComplicationSlot elements.
The
Configurationelement references previously defined configuration elements, such asBooleanConfiguration, using theidattribute. TheConfigurationelements sets the chosen value for this configuration option using theoptionIdattribute.The
ComplicationSlotelement can be used to specify theDefaultProviderPolicyfor a givenFlavor.
Recommended for you
- Note: link text is displayed when JavaScript is off
- Flavor
- ListConfiguration
- ColorConfiguration