Android Wearable API: how to pass a dynamic List?

2019-09-10 08:30发布

This is how I'm using DataAPI

    PutDataMapRequest dataMapReq = PutDataMapRequest.create(PATH);
    dataMapReq.getDataMap().putFloatArray(KEY, list);
    PutDataRequest putDataReq = dataMapReq.asPutDataRequest();
    Wearable.DataApi.putDataItem(mGoogleApiClient, putDataReq);

list could be an array[] or ArrayList<>. If I add a new element then I'll have to put the list in the data map again. This will cause a retransmission of every previously inserted elements?

1条回答
我只想做你的唯一
2楼-- · 2019-09-10 09:02

Yes, if you change an element in the array/list, you need to put another data item and it will replace the old one. That will cause retransmission to the other devices.

In general, I wouldn't worry about that retransmission. Since there is a limit of how much you can send in the DataItem, you are probably not sending too much data. If you are still worried about it, consider partitioning the data and sending several data items (for example send four sub-arrays of floats and merge them on the other side). Do not send each float a separate data item (enormous overhead).

查看更多
登录 后发表回答