0

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?

dors
  • 5,802
  • 8
  • 45
  • 71
  • What do you mean by 'every time I make a request?' – ianhanniballake Dec 28 '14 at 05:57
  • I mean that I will get to onDataChange() every time I call Wearable.DataApi.putDataItem(), regardless of if it is the same. I would have used the MessgeAPI, but it seems that the payload limitation is lower than the one the DataAPI has, and I need to pass an Asset (which makes it crash using the MessageAPI as mentioned in my post: http://stackoverflow.com/questions/27669318/wear-getting-indexoutofbounds-exception-from-datamap-frombytearraymessageeven) – dors Dec 28 '14 at 06:46

1 Answers1

0

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 .

Roy Solberg
  • 18,133
  • 12
  • 49
  • 76