Android Wear complication update behaviour

843 views Asked by At

Im trying to program complication service in Android Wear based using the RandomNumberProviderService as guide but im having trouble coming out with a way of separating the behaviour when I tap the complication and when I only need to update the info programatically (when the watch recieves a DataApi change). Tapping the complication should send a Message to the handheld, and it does now but I have no way of only updating the info on the complication.

1

There are 1 answers

0
Mr.Rebot On

Check the ComplicationSimpleWatchFaceService:

        /*
         * Called when there is updated data for a complication id.
         */
        @Override
        public void onComplicationDataUpdate(
                int complicationId, ComplicationData complicationData) {
            Log.d(TAG, "onComplicationDataUpdate() id: " + complicationId);

            // Adds/updates active complication data in the array.
            mActiveComplicationDataSparseArray.put(complicationId, complicationData);
            invalidate();
        }

According to the Receiving data and rendering complications documentation:

To start receiving complication data, a watch face calls setActiveComplications, in the WatchFaceService.Engine class, with a list of watch face complication IDs. A watch face creates these IDs to uniquely identify slots on the watch face where complications can appear, and passes them to the createProviderChooserIntent method to allow the user to decide which complication should go in which slot.

Complication data is delivered via the onComplicationDataUpdate (of WatchFaceService.Engine) callback.

Kindly check the Android WatchFace Sample the link you've provided is part of this example), this demonstrates how to create watch faces for android wear and includes a phone app and a wearable app. The wearable app has a variety of watch faces including analog, digital, opengl, calendar, steps, interactive, etc.

Hope this helps.