RxWear
RxWear copied to clipboard
Uri for DataListener not properly computed
I'm sending data on the mobile through
rxWear.data().putDataMap().to("/myPath")
which seems to properly create the Uri and results in wear://<nodeId>/myPath
but on the wear I listen like:
rxWear.data().listen("/myPath", DataApi.FILTER_LITERAL)
which gives me: wear:/myPath
In your Implementation you create the Uri with a Uri.Builder but do not set the host (which is missing in the above uri)
This bug results has the problem that the listen command is triggered by EVERY data-update, no matter of the specified Uri, see https://developers.google.com/android/reference/com/google/android/gms/wearable/DataClient.html#addListener(com.google.android.gms.wearable.DataClient.OnDataChangedListener,%20android.net.Uri,%20int)
Hi,
I ran into the same "issue" and figured out I didn't use the proper filter when getting or listening to data or messages.
For data, use:
rxWear.data().get(path).compose(DataItemGetDataMap.filterByPath(path)),
rxWear.data().listen(path, DataApi.FILTER_LITERAL).compose(DataEventGetDataMap.filterByPathAndType(path, DataEvent.TYPE_CHANGED))
Note the filterByPath
and filterByPathAndType
parts. The original examples are with .nofilter()
, that's why you get notified for any data update.
Same goes for messages, use MessageEventGetDataMap.filterByPath(path)
if it's needed.
Cheers!