I implemented a watchface compatible 1.x few months ago (2.x to come). The app has been thoroughly tested with the debug version on a real device, coupled with an emulator, but also on a moto 360 first generation. Everything was working like a charm. Both devices were communicating back and forth and the app is ready to be deployed. I did a last round of tests with the release build, installed on real devices as well: all good, The app was ready to be published!
I pushed an alpha version on the store for few alpha testers. And here appeared the issue: the phone is not interacting properly with the watch anymore. More specifically: the data is sent from the phone but the onDataChanged
callback on the watch side does not seem to be called in this specific case. I really do not get it because the release build is perfectly working when I install it manually on my test device.
The data is sent (phone side):
public static void putConfigDataItem(GoogleApiClient googleApiClient, final DataMap newConfig) {
PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(DataLayerKeys.PATH_WITH_FEATURE);
putDataMapRequest.setUrgent();
DataMap configToPut = putDataMapRequest.getDataMap();
configToPut.putAll(newConfig);
Wearable.DataApi.putDataItem(googleApiClient, putDataMapRequest.asPutDataRequest()).setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
@Override
public void onResult(@NonNull DataApi.DataItemResult dataItemResult) {
Timber.d("putDataItem result status: " + dataItemResult.getStatus());
}
});
}
Data supposed to be received here (watch side), but not working:
public class HaikuService extends CanvasWatchFaceService {
@Override
public Engine onCreateEngine() {
return new HaikuEngine();
}
private class HaikuEngine extends Engine implements DataApi.DataListener,
GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
private final GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(HaikuService.this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Wearable.API)
.build();
//...
@Override // DataApi.DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
//... not called
}
//...
}
}
Note: The wear and mobile modules have the same applicationId.
The Wearable.DataApi.putDataItem
is not working in from the phone to the watch but Wearable.MessageApi.sendMessage
is actually working. I am using it to communicate back and forth between the phone and the watch to grant the location permission at the first start and there everything is working as expected.
I have been looking all over the internet no way to find anything. Maybe I am missing something really obvious.. I have spent days on this issue and no way to find out. I would be eternally grateful to anyone who could help me or provide any tips.