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:
BooleanConfiguration
ColorConfiguration
ListConfiguration
ComplicationSlot
Since version 2
Syntax
<Flavor id="string" displayName="string" icon="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" icon="flavor_1_preview">
<Configuration id="themeColor" optionId="0"/>
<ComplicationSlot slotId="0">
<DefaultProviderPolicy
defaultSystemProvider="DAY_OF_WEEK"
defaultSystemProviderType="SHORT_TEXT"/>
</ComplicationSlot>
</Flavor>
<Flavor id="2" displayName="2nd flavor" icon="flavor_2_preview">
<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 resource ID corresponding to the text that is displayed in the companion.
Optional attributes
The following attributes are optional:
icon
- A resource ID corresponding to the drawable resource which is shown in the companion. This should have a maximum size of 360x360 px.
screenReaderText
- A resource ID corresponding to the text which is used if the user has TalkBack enabled.
Inner elements
The Flavor
element must contain at least one Configuration
element and can
optionally include ComplicationSlot
elements.
The
Configuration
element references previously defined configuration elements, such asBooleanConfiguration
, using theid
attribute. TheConfiguration
elements sets the chosen value for this configuration option using theoptionId
attribute.The
ComplicationSlot
element can be used to specify theDefaultProviderPolicy
for a givenFlavor
.
Recommended for you
- Note: link text is displayed when JavaScript is off
- Flavor
- ListConfiguration
- ColorConfiguration