0

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 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)?

Here is my watchface.xml code in which I have created the watch face:

<?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.xml file.

<application
   android:name=".WatchFaceApplication"
   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

3
  • Please provide enough code so others can better understand or reproduce the problem. Commented Apr 8 at 20:53
  • you need to implement a complication. you can update the complication data from your app. Commented Apr 9 at 14:48
  • Can you provide code sample for updating data to xml? Commented Apr 10 at 5:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.