Saturday 7 November 2020

Android Wear: can't send DataItem from Wearable to Phone

I'm trying to send a DataItem from my wearable to the phone, during the Wearable splash screen activity:

    protected void onResume() {
        super.onResume();
        Wearable.getDataClient(context).putDataItem(putDataRequest)
    }

(putDataRequest is properly constructed, and includes a timestamp field so that the data is changing on each call)

The onComplete callback from putDataItem indicates a successful send.

On the phone side, I've implemented a WearableListenerService, with the correct intent filter in the AndroidManifest.

When the wearable calls putDataItem, I see the following in the logs on the phone:

11-04 16:46:47.320  2518  4141 W ChimeraUtils: Module com.google.android.gms.gcm has empty metadata display_name_string_id
11-04 16:46:47.338 17648 17648 I GCM     : Message from 745476177629
11-04 16:46:47.338 17648 17648 E GCM     : Dropping message to GMS from 745476177629 as no component is set

It appears that the phone is getting some sort of message from the wearable, but it is not recognized and so gets dropped. My WearableListenerService.onDataChanged callback on the phone never gets called.

I've verified that package name, version, and signing key are identical between phone and wearable apps.

Google searches for the log messages have not been fruitful. Does anyone know why my wearable Data Layer messages aren't getting synched to the phone app?

Edit to add: I am able to communicate between the watch and the phone if I use the sendMessage() API - indeed that is what I am trying to replace here, since sendMessage isn't reliably waking my app up when the phone is in a low-power state.



from Android Wear: can't send DataItem from Wearable to Phone

No comments:

Post a Comment