本文介绍了WearableListenerService,onDataChanged()不叫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我跟着教程来调用从手机可穿戴的活动,在这里How从手持设备发送通知戴开活动磨损设备。不过,我抓住从答案的来源$ C $ C。但是,我不能让它运行。它看起来像 onDataChanged()
永远不会被调用。请问这是对自己的一个问题,因为它似乎示例适用于其他人。我在奇巧4.4.2,如果该事项。
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 the source code from the answer. However, I couldn't get it running. It looks like onDataChanged()
is never called. I ask this as a question on its own because it seems the example works for others.I'm on KitKat 4.4.2, if that matters.
任何提示的地方进行检查,谢谢。
Any tip where to check, thanks.
推荐答案
有两件事情,你可以检查:
There are two things you can check:
-
的packageName
磨损的应用程序应该是相同的的packageName
设备应用程序的 -
onDataChanged()
当数据的真正改变的被称为只。如果你把相同的数据到DataApi多次的方法,直到你写不同的数据只被调用一次。可以添加一个时间戳数据,以确保该方法被调用一次为每个写操作。但是,使用DataApi是潜在于电池使用方面比发送消息更为昂贵。所以,如果你只是想将数据放入DataApi后触发一个操作,只需发送一个消息,当您完成。
packageName
of the wear app should be identical topackageName
of the device apponDataChanged()
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.
这篇关于WearableListenerService,onDataChanged()不叫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!