Reputation: 23
I have been using the following intent-filter in my manifest and everything worked fine:
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
This has been deprecated so I am trying to use:
<action android:name="com.google.android.gms.wearable.CAPABILITY_CHANGED" />
<action android:name="com.google.android.gms.wearable.MESSAGE_RECEIVED" />
<action android:name="com.google.android.gms.wearable.DATA_CHANGED" />
<action android:name="com.google.android.gms.wearable.CHANNEL_EVENT" />
<data android:scheme="wear" android:host="*" android:pathPrefix="/mypath" />
I can receive messages fine but onPeerConnected never gets called now.
public class WearListenerService extends WearableListenerService {
@Override
public void onPeerConnected(Node peer) {
Log.d("Wear Service", "Peer Connected");
}
@Override
public void onMessageReceived(MessageEvent messageEvent) {
Log.d("Wear Service", "Message Received");
}
}
Everything works perfect if I switch back to using the old BIND_LISTENER instead.
Upvotes: 2
Views: 653
Reputation: 6635
onPeerConnected
was deprecated at the same time as BIND_LISTENER
, so when you stop using the latter, you need to stop using the former as well.
For comparable functionality, use the Cabability API: CAPABILITY_CHANGED
in your manifest, and a CapabilityListener
in your Java code. More details here: https://developer.android.com/training/wearables/data-layer/messages.html#SendMessage
Upvotes: 5