I try to send an asset (a test image) from the mobile to the wear device. I follow the official Guide for transfering Assets I took the "DataLayerListenerService". The problem is, that I get "data item is not resolved" on DataMapItem.fromDataItem(dataItem);
"data item is not resolved".
I am really stuck here and I don't get it from the documentation. Plz help.
public void onDataChanged(DataEventBuffer dataEvents) {
for (DataEvent event : dataEvents) {
if (event.getType() == DataEvent.TYPE_CHANGED &&
event.getDataItem().getUri().getPath().equals("/image")) {
DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
Asset profileAsset = dataMapItem.getDataMap().getAsset("profileImage");
Bitmap bitmap = loadBitmapFromAsset(profileAsset);
// Do something with the bitmap
}
}
}
You didn't call getDataItem()
on the DataEvent
instance.
This line:
DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
should be instead:
DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem());