WearableListenerService, onDataChanged() is not called

前端 未结 7 949
野趣味
野趣味 2020-12-11 01:05

I followed the tutorial to invoke a Wearable activity from phone, posted here How to send notification from handheld to wear to open Activity on wear device. However, I grab

7条回答
  •  情话喂你
    2020-12-11 01:25

    There are two things you can check:

    • packageName of the wear app should be identical to packageName of the device app
    • onDataChanged() gets only called when the data really changes. If you put the same data into the DataApi multiple times, the method is only called once until you write different data. You could add a timestamp to the data to make sure that the method gets called once for each write operation. However, using the DataApi is potentially more expensive in terms of battery usage than sending a message. So if you just want to trigger an action after putting data into the DataApi, simply send a message when you are done.

提交回复
热议问题