EDIT:
Of course I missed something embarrassingly obvious... The GoogleApiClient was not connected.
I'm trying to synchronise some data between my phone and a watch. I decided to use the Wearable.DataApi.putDataItem
method for that but when I try to retrieve the data on the wearable the itemBuffer
is empty... I must be doing something wrong and can't figure out what it is.
Provide the data:
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(article);
PutDataRequest request = PutDataRequest
.createWithAutoAppendedId(WearApiConstants.NEWS_BREAKING)
.setData(bos.toByteArray());
Wearable.DataApi.putDataItem(mGoogleApiClient, request).await();
Retrieve the data:
Uri.Builder builder = new Uri.Builder();
builder.scheme(PutDataRequest.WEAR_URI_SCHEME)
.path(WearApiConstants.NEWS_BREAKING);
Uri uri = builder.build();
DataItemBuffer itemBuffer =
Wearable.DataApi.getDataItems(mGoogleApiClient, uri, DataApi.FILTER_PREFIX)
.await();
Did I miss anything obvious? If not, can you suggest an approach to debug this problem?