[英]Wear addListener's onDataChanged isn't being called
I'm encountering a very weird scenario. 我遇到一个非常奇怪的情况。 I implemented both
WearableListenerService
and Wearable.DataApi.addListener
on my wear device, and I am periodically sending data updates from my phone. 我在
WearableListenerService
设备上同时实现了WearableListenerService
和Wearable.DataApi.addListener
,并且定期从手机发送数据更新。 The WearableListenerService
is properly getting onDataChanged
callbacks, but my listener in the main activity isn't.. WearableListenerService
正确获取onDataChanged
回调,但主要活动中的侦听器却没有。
This is my setup for the activity: 这是我为活动设置的:
onStart() {
super.onStart();
googleApiClient.connect();
}
onStop() {
googleApiClient.disconnect();
Wearable.DataApi.removeListener(googleApiClient, this);
super.onStop();
}
onConnected() {
Wearable.DataApi.addListener(googleApiClient, this);
}
onDataChanged() {
// never gets called
}
I can post more code, but above is the general gist. 我可以发布更多代码,但以上是一般要点。 On the other hand, my
WearableListenerService
is properly declared in the AndroidManifest
, and simply prints out logs when it receives onDataChanged
. 另一方面,我的
WearableListenerService
在AndroidManifest
已正确声明,并且在接收到onDataChanged
时仅打印出日志。
Is there anything obvious I'm missing here? 有什么明显的我想念的地方吗?
For this you will have to implement one of the following interfaces in your activity: 为此,您将必须在活动中实现以下接口之一:
See 'With a Listener Activity' part of this android developer documentation. 请参阅此 android开发人员文档的“使用侦听器活动”部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.