Android穿戴API:如何通过一个动态的名单? [英] Android Wearable API: how to pass a dynamic List?

查看:214
本文介绍了Android穿戴API:如何通过一个动态的名单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我如何使用DataAPI

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);

列表可以是一个 []数组的ArrayList<>
如果我添加一个新的元素,则我将不得不中的数据映射列表一次。这将导致每$ P $的重传pviously插入的元素?

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?

推荐答案

是的,如果你在数组/列表中更改的元素,你需要把另外一个数据项,它会取代旧的。这将导致重传的其它设备。

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.

在一般情况下,我不会担心重传。既然有多少你可以在发送的DataItem的限制,你可能不发送太多的数据。如果你还在担心它,可以考虑分割数据和发送多个数据项(例如发送花车的四个子阵列,并合并他们在另一边)。 不要发送每个浮点单独的数据项(巨大的开销)。

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).

这篇关于Android穿戴API:如何通过一个动态的名单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆