Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uri for DataListener not properly computed #7

Open
chriswiesner opened this issue Jan 9, 2018 · 1 comment
Open

Uri for DataListener not properly computed #7

chriswiesner opened this issue Jan 9, 2018 · 1 comment

Comments

@chriswiesner
Copy link

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)

@istvangal
Copy link

istvangal commented May 10, 2018

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants