public interface WearableMessageListener

Notified when the peer app sends a live message.

Callbacks arrive on the EDT. A message that arrived while your app was starting – including the one that caused the platform to launch it – is replayed to the first listener you register, so register from your app’s init() rather than from a form.

Methods

public abstract WearableMessage messageReceived(WearableMessage message, boolean expectsReply)Called when a message arrives from the peer app.

Method details

messageReceived

public abstract WearableMessage messageReceived(WearableMessage message, boolean expectsReply)

Called when a message arrives from the peer app.

If the sender asked for a reply, answer it by returning a message; returning null sends an empty reply. The sender is blocked waiting, so answer quickly and do slow work afterwards.

Parameters

message WearableMessage
the received payload, addressed to the path the sender chose
expectsReply boolean
true when the sender is waiting for an answer

Returns

the reply to send back, or null for none