Android 可穿戴Listener服务连续绑定/解除绑定
我制作了一个简单的smartwatch应用程序,可以连接到手机发送一些数据。然而,它不断地绑定和解除绑定,导致很多延迟。日志显示Android 可穿戴Listener服务连续绑定/解除绑定,android,service,wear-os,sony-smartwatch,Android,Service,Wear Os,Sony Smartwatch,我制作了一个简单的smartwatch应用程序,可以连接到手机发送一些数据。然而,它不断地绑定和解除绑定,导致很多延迟。日志显示 01-10 22:26:17.780 13094-17893/com.verbraeken.joost V/WearableLS: bindService: com.verbraeken.joost/.WearListenerService 01-10 22:26:17.783 13094-17893/com.verbraeken.joost V/WearableL
01-10 22:26:17.780 13094-17893/com.verbraeken.joost V/WearableLS: bindService: com.verbraeken.joost/.WearListenerService
01-10 22:26:17.783 13094-17893/com.verbraeken.joost V/WearableLS: unbindService: com.verbraeken.joost/.WearListenerService
在清单中,服务声明为:
<service android:name="WearListenerService">
<intent-filter>
<action android:name="com.google.android.gms.wearable.DATA_CHANGED"/>
<action android:name="com.google.android.gms.wearable.MESSAGE_RECEIVED"/>
<action android:name="com.google.android.gms.wearable.CAPABILITY_CHANGED"/>
<action android:name="com.google.android.gms.wearable.CHANNEL_EVENT"/>
<data android:path="/WEAR_ORIENTATION" android:host="*" android:scheme="wear"/>
</intent-filter>
</service>
该服务本身扩展了WearableListenerService,只不过是一个onMessageReceived方法
服务每秒绑定/取消绑定大约50次的原因是什么?根据文档,这是服务的默认行为(绑定和取消绑定):
可穿戴ListenerService(用于服务)
扩展使您能够侦听服务中的重要数据层事件。当需要发送数据项或消息时,系统将管理绑定到服务的生命周期,,当不需要工作时,系统将解除绑定服务
请检查您的实现,以验证您遇到的错误(每秒绑定/取消绑定x次)
希望这有帮助。哪款索尼智能手表?索尼智能手表3感谢您的帮助!有没有办法让服务绑定,直到我告诉它解除绑定?