android Wearable-DataApi: onDataChanged method is not being called

building a watch face sending data from mobile app to watchface using DataItem using Wearable.DataApi

but on watch face service "onDataChanged" method is not being called randomly
ONDATACHANGED WEARABLE_DATAAPI NOT CALLED

Submitted by sunil On Tuesday, 01 December 2015.
Category: Javascript

0
1 Answers.
 
Super User
laser

Re:android Wearable-DataApi: onDataChanged method is not being called

first make sure com.google.android.gms:play-services-wearable:{version} on mobile and wear app is same on build.gradle

if it is then try
PutDataMapRequest putDataMapReq = PutDataMapRequest.create("/data_key"); 
        putDataMapReq.getDataMap().putString("data", "your data here"); 
        PutDataRequest putDataReq = putDataMapReq.asPutDataRequest(); 
        Wearable.DataApi.deleteDataItems(mGoogleApiClient, putDataReq.getUri());// trick is in this line here :) 
        Wearable.DataApi.putDataItem(mGoogleApiClient, putDataReq);
Submitted by Super User On Tuesday, 01 December 2015
0