I have a custom watch face app and a separate watch app that successfully communicate using WatchFaceService
on Galaxy Watch 6 (Wear OS 4.0). The watch face dynamically updates via data sent from the watch app.
However, on the Galaxy Watch 7 (Wear OS 5.0), which only supports the Watch-Face-Format (WFF) XML, I had to switch from WatchFaceService
to watchface.xml
. Since then, I’m unable to dynamically update <PartText>
elements on the watch face from the watch app.
I am using Android Studio for the development.
Could you please provide guidance or sample code on how to send and update values dynamically from a watch app to a WFF-based watch face (Galaxy Watch 7)?
Thank you.
Are you using a companion app to update it dynamically?
imrulanwar836:
companion app
No, I have one wear os app installed in Galaxy Watch 7 and I need to send data from wear os app to watch face app which I have designed using Watch Face Format. As Galaxy Watch 7 only supports WFF XML format.
can you please provide a sample project? and give an example of what you are trying to do?
I’ll try to recreate it.
This is my code for watchface.xml:
<?xml version="1.0" encoding="UTF-8"?>
<WatchFace
clipShape="CIRCLE"
height="450"
width="450">
<Scene backgroundColor="#ff000000">
<PartImage
alpha="80"
height="450"
pivotX="0.5"
pivotY="0.5"
scaleX="0.9"
scaleY="0.9"
width="450"
x="0"
y="0">
<Image resource="@drawable/icon_screensaver">
</Image>
<Launch target="com.xyz.demo" />
</PartImage>
<DigitalClock
alpha="255"
height="200"
width="450"
x="125"
y="0">
<TimeText
align="CENTER"
alpha="255"
format="hh:mm"
height="190"
hourFormat="SYNC_TO_DEVICE"
width="190"
x="0"
y="0">
<Font
color="#ffffffff"
family="roboto_regular"
size="60"
slant="NORMAL"
weight="NORMAL" />
</TimeText>
</DigitalClock>
<PartImage
name="alarm_icon"
alpha="255"
anchorX="0.5"
anchorY="0.5"
height="70"
width="70"
x="190"
y="150">
<Image resource="@drawable/unassigned_light" />
</PartImage>
<PartImage
name="bg_alarm"
alpha="206"
height="450"
pivotX="0.5"
pivotY="0.5"
scaleX="0.45"
scaleY="0.45"
width="450"
x="0"
y="0">
<Image resource="@drawable/circular_button_orange">
</Image>
</PartImage>
<PartText
name="alarm_count"
height="200"
width="450"
x="-60"
y="150">
<Text
align="CENTER"
ellipsis="FALSE"
width="40">
<Font
color="#ffffffff"
family="SYNC_TO_DEVICE"
size="26"
slant="NORMAL"
weight="NORMAL">
10
</Font>
</Text>
</PartText>
<PartText
name="alarm_text"
height="200"
width="450"
x="-60"
y="186">
<Text
align="CENTER"
ellipsis="FALSE">
<Font
color="#ffffffff"
family="SYNC_TO_DEVICE"
size="26"
slant="NORMAL"
weight="NORMAL">
Alarms
</Font>
</Text>
</PartText>
<PartText
name="day_date"
anchorX="0.5"
height="50"
pivotX="0.5"
width="480"
x="-10"
y="320">
<Text align="CENTER">
<Font
color="#ffffffff"
family="SYNC_TO_DEVICE"
size="30"
slant="NORMAL"
weight="NORMAL">
<Template>day_of_week
<Parameter expression="[DAY_OF_WEEK_F]" />
</Template>
<Text>,</Text>
<Template>day_of_week
<Parameter expression="[DAY_Z]" />
</Template>
<Text>.</Text>
<Template>day_of_week
<Parameter expression="[MONTH_Z]" />
</Template>
<Text>.</Text>
<Template>day_of_week
<Parameter expression="[YEAR]" />
</Template>
</Font>
</Text>
</PartText>
<PartText
name="day_date"
height="30"
width="70"
x="190"
y="380">
<Text align="CENTER">
<Font
color="#E5FFFFFF"
family="SYNC_TO_DEVICE"
size="26"
slant="NORMAL"
weight="BOLD">
<Template>battery_percent
<Parameter expression="[BATTERY_PERCENT]" />
</Template>
<Text>%</Text>
</Font>
</Text>
</PartText>
<PartImage
name="image_apronic"
anchorX="0.5"
anchorY="0.5"
height="30"
width="100"
x="170"
y="420">
<Image resource="@drawable/logo_homepage">
</Image>
</PartImage>
</Scene>
</WatchFace>
This is how I defined in AndroidManifest file:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.DeviceDefault">
<meta-data
android:name="com.google.android.wearable.standalone"
android:value="true" />
<property
android:name="com.google.wear.watchface.format.version"
android:value="2" />
<meta-data
android:name="com.google.android.wearable.watchface.format"
android:resource="@xml/watch_face" />
<meta-data
android:name="com.google.android.wearable.watchface.info"
android:resource="@xml/watch_face_info" />
</application>
I need to update bg_alarm based on condition and alarm_count defined in watchface.xml which I need to get from other app.
This is watchface.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<WatchFace
clipShape="CIRCLE"
height="450"
width="450">
<Scene backgroundColor="#ff000000">
<PartImage
alpha="80"
height="450"
pivotX="0.5"
pivotY="0.5"
scaleX="0.9"
scaleY="0.9"
width="450"
x="0"
y="0">
<Image resource="@drawable/icon_screensaver">
</Image>
<Launch target="com.xyz.demo" />
</PartImage>
<DigitalClock
alpha="255"
height="200"
width="450"
x="125"
y="0">
<TimeText
align="CENTER"
alpha="255"
format="hh:mm"
height="190"
hourFormat="SYNC_TO_DEVICE"
width="190"
x="0"
y="0">
<Font
color="#ffffffff"
family="roboto_regular"
size="60"
slant="NORMAL"
weight="NORMAL" />
</TimeText>
</DigitalClock>
<PartImage
name="alarm_icon"
alpha="255"
anchorX="0.5"
anchorY="0.5"
height="70"
width="70"
x="190"
y="150">
<Image resource="@drawable/unassigned_light" />
</PartImage>
<PartImage
name="bg_alarm"
alpha="206"
height="450"
pivotX="0.5"
pivotY="0.5"
scaleX="0.45"
scaleY="0.45"
width="450"
x="0"
y="0">
<Image resource="@drawable/circular_button_orange">
</Image>
</PartImage>
<PartText
name="alarm_count"
height="200"
width="450"
x="-60"
y="150">
<Text
align="CENTER"
ellipsis="FALSE"
width="40">
<Font
color="#ffffffff"
family="SYNC_TO_DEVICE"
size="26"
slant="NORMAL"
weight="NORMAL">
10
</Font>
</Text>
</PartText>
<PartText
name="alarm_text"
height="200"
width="450"
x="-60"
y="186">
<Text
align="CENTER"
ellipsis="FALSE">
<Font
color="#ffffffff"
family="SYNC_TO_DEVICE"
size="26"
slant="NORMAL"
weight="NORMAL">
Alarms
</Font>
</Text>
</PartText>
<PartText
name="day_date"
anchorX="0.5"
height="50"
pivotX="0.5"
width="480"
x="-10"
y="320">
<Text align="CENTER">
<Font
color="#ffffffff"
family="SYNC_TO_DEVICE"
size="30"
slant="NORMAL"
weight="NORMAL">
<Template>day_of_week
<Parameter expression="[DAY_OF_WEEK_F]" />
</Template>
<Text>,</Text>
<Template>day_of_week
<Parameter expression="[DAY_Z]" />
</Template>
<Text>.</Text>
<Template>day_of_week
<Parameter expression="[MONTH_Z]" />
</Template>
<Text>.</Text>
<Template>day_of_week
<Parameter expression="[YEAR]" />
</Template>
</Font>
</Text>
</PartText>
<PartText
name="day_date"
height="30"
width="70"
x="190"
y="380">
<Text align="CENTER">
<Font
color="#E5FFFFFF"
family="SYNC_TO_DEVICE"
size="26"
slant="NORMAL"
weight="BOLD">
<Template>battery_percent
<Parameter expression="[BATTERY_PERCENT]" />
</Template>
<Text>%</Text>
</Font>
</Text>
</PartText>
<PartImage
name="image_apronic"
anchorX="0.5"
anchorY="0.5"
height="30"
width="100"
x="170"
y="420">
<Image resource="@drawable/logo_homepage">
</Image>
</PartImage>
</Scene>
</WatchFace>
This is how I have defined in AndroidManifest file:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.DeviceDefault">
<meta-data
android:name="com.google.android.wearable.standalone"
android:value="true" />
<property
android:name="com.google.wear.watchface.format.version"
android:value="2" />
<meta-data
android:name="com.google.android.wearable.watchface.format"
android:resource="@xml/watch_face" />
<meta-data
android:name="com.google.android.wearable.watchface.info"
android:resource="@xml/watch_face_info" />
</application>
I have to update the alarm_count and bg_alarm defined in watchface.xml based on condition which I have to get from another app which is installed in Galaxy Watch 7