public abstract class

WearableListenerService

extends Service
implements DataApi.DataListener MessageApi.MessageListener NodeApi.NodeListener
java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ com.google.android.gms.wearable.WearableListenerService

Class Overview

Receives events from other nodes, such as data changes, messages or connectivity events.

The life-cycle of this service is managed by Android Wear. This service will be bound to and events delivered as a result of changes through the DataApi, MessageApi as well as events indicating a device has connected or disconnected from the Android Wear network.

Applications expecting to be notified of events while in the background should extend this class. Activities and other short-lived Android components may use addListener(GoogleApiClient, DataApi.DataListener), addListener(GoogleApiClient, MessageApi.MessageListener) and addListener(GoogleApiClient, NodeApi.NodeListener) to receive events for a limited period of time.

Only one WearableListenerService may be specified for an application.

Implementors could use a LocalBroadcastManager to dispatch events to other components in an application.

Summary

[Expand]
Inherited Constants
From class android.app.Service
From class android.content.Context
From interface android.content.ComponentCallbacks2
Public Constructors
WearableListenerService()
Public Methods
final IBinder onBind(Intent intent)
void onCreate()
void onDataChanged(DataEventBuffer dataEvents)
Receives data changed events.
void onDestroy()
void onMessageReceived(MessageEvent messageEvent)
Receives message events.
void onPeerConnected(Node peer)
Receives peer connected events.
void onPeerDisconnected(Node peer)
Receives peer disconnected events.
[Expand]
Inherited Methods
From class android.app.Service
From class android.content.ContextWrapper
From class android.content.Context
From class java.lang.Object
From interface android.content.ComponentCallbacks
From interface android.content.ComponentCallbacks2
From interface com.google.android.gms.wearable.DataApi.DataListener
From interface com.google.android.gms.wearable.MessageApi.MessageListener
From interface com.google.android.gms.wearable.NodeApi.NodeListener

Public Constructors

public WearableListenerService ()

Public Methods

public final IBinder onBind (Intent intent)

public void onCreate ()

public void onDataChanged (DataEventBuffer dataEvents)

Receives data changed events. The provided buffer will be closed after this method completes. Use freeze() on items in the buffer to use them outside of this callscope.

Multiple data events may delivered in a single call and may only contain final-state modifications of a data item. (Eg, multiple calls to putDataItem changing the value of the data item's getData() may only appear as a single event, with the last modification expressed).

Applications needing to track the of all its data items, may use getDataItems(GoogleApiClient) on boot to retrieve all existing data items.

public void onDestroy ()

public void onMessageReceived (MessageEvent messageEvent)

Receives message events.

public void onPeerConnected (Node peer)

Receives peer connected events.

Node events are determined by the connectivity between two Android Wear devices. For example, a wearable turned on will connect to a phone and trigger a onPeerConnected(Node) event.

public void onPeerDisconnected (Node peer)

Receives peer disconnected events.

Node events are determined by the connectivity between two Android Wear devices. For example, a wearable moving out of range of a phone will trigger a onPeerDisconnected(Node) event.