问题
I want WearableListenerService to call onDataChanged() every time I make a request. I am aware that onDataChanged() is only called, well, on data change and not every time.
I can add dummy data with the date to make this happen, but that feels patchy.
Is there a more elegant way to achieve what I want to do?
回答1:
You might be able to turn the situation around a bit. As you say, onDataChanged
is only called whenever there's a change and you should probably keep handling that.
Whenever you need to know the current value you can use one of the Wearable.DataApi.getDataItem
(s) methods as described on https://developer.android.com/reference/com/google/android/gms/wearable/DataApi.html .
来源:https://stackoverflow.com/questions/27665686/making-wearablelistenerservice-ondatachanged-call-on-every-putdatamaprequest