简体   繁体   中英

WearableListenerService binding/unbinding continuously

I made a simple smartwatch app that connects to the phone to send some data. However, it continously binds and unbinds causing a lot of lag. Logcat shows

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

In the manifest the service is declared as:

<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>

The service itself does extend WearableListenerService and has nothing more than an onMessageReceived method.

What could be the reason that the service binds/unbinds approximately 50 times per second?

It is a default behavior (bind and unbind) of the service, based from the documentation - Sending and Syncing Data :

WearableListenerService (for services)

Extending WearableListenerService lets you listen for important data layer events in a service. The system manages the lifecycle of the WearableListenerService , binding to the service when it needs to send data items or messages and unbinding the service when no work is needed .

Kindly check your implementation, to verify the error you are encountering (bind/unbind x times per second).

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM