WearableListenerService | Android Developers

Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

Language
close

- - About
  - Wear
  - TV
  - Auto
- - Get Started
  - Devices
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
  - Google Services
  - Samples
- - Google Play
  - Essentials
  - Get Users
  - Engage & Retain
  - Monetize
  - Analyze
  - Tools & Reference
  - Developer Stories

## Results

Loading...
Summary: Inherited Constants | Ctors | Methods | Inherited Methods | [Expand All]
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
int | START_CONTINUATION_MASK |
int | START_FLAG_REDELIVERY |
int | START_FLAG_RETRY |
int | START_NOT_STICKY |
int | START_REDELIVER_INTENT |
int | START_STICKY |
int | START_STICKY_COMPATIBILITY |
From class android.content.Context
String | ACCESSIBILITY_SERVICE |
String | ACCOUNT_SERVICE |
String | ACTIVITY_SERVICE |
String | ALARM_SERVICE |
String | APPWIDGET_SERVICE |
String | APP_OPS_SERVICE |
String | AUDIO_SERVICE |
String | BACKUP_SERVICE |
String | BATTERY_SERVICE |
int | BIND_ABOVE_CLIENT |
int | BIND_ADJUST_WITH_ACTIVITY |
int | BIND_ALLOW_OOM_MANAGEMENT |
int | BIND_AUTO_CREATE |
int | BIND_DEBUG_UNBIND |
int | BIND_IMPORTANT |
int | BIND_NOT_FOREGROUND |
int | BIND_WAIVE_PRIORITY |
String | BLUETOOTH_SERVICE |
String | CAMERA_SERVICE |
String | CAPTIONING_SERVICE |
String | CLIPBOARD_SERVICE |
String | CONNECTIVITY_SERVICE |
String | CONSUMER_IR_SERVICE |
int | CONTEXT_IGNORE_SECURITY |
int | CONTEXT_INCLUDE_CODE |
int | CONTEXT_RESTRICTED |
String | DEVICE_POLICY_SERVICE |
String | DISPLAY_SERVICE |
String | DOWNLOAD_SERVICE |
String | DROPBOX_SERVICE |
String | HDMI_CONTROL_SERVICE |
String | INPUT_METHOD_SERVICE |
String | INPUT_SERVICE |
String | JOB_SCHEDULER_SERVICE |
String | KEYGUARD_SERVICE |
String | LAUNCHER_APPS_SERVICE |
String | LAYOUT_INFLATER_SERVICE |
String | LOCATION_SERVICE |
String | MEDIA_PROJECTION_SERVICE |
String | MEDIA_ROUTER_SERVICE |
String | MEDIA_SESSION_SERVICE |
int | MODE_APPEND |
int | MODE_ENABLE_WRITE_AHEAD_LOGGING |
int | MODE_MULTI_PROCESS |
int | MODE_PRIVATE |
int | MODE_WORLD_READABLE |
int | MODE_WORLD_WRITEABLE |
String | NETWORK_SCORE_SERVICE |
String | NFC_SERVICE |
String | NOTIFICATION_SERVICE |
String | NSD_SERVICE |
String | PERSISTENT_DATA_BLOCK_SERVICE |
String | POWER_SERVICE |
String | PRINT_SERVICE |
String | RESTRICTIONS_SERVICE |
String | SEARCH_SERVICE |
String | SENSOR_SERVICE |
String | STORAGE_SERVICE |
String | TELECOM_SERVICE |
String | TELEPHONY_SERVICE |
String | TELEPHONY_SUBSCRIPTION_SERVICE |
String | TEXT_SERVICES_MANAGER_SERVICE |
String | TV_INPUT_SERVICE |
String | UI_MODE_SERVICE |
String | USAGE_STATS_SERVICE |
String | USB_SERVICE |
String | USER_SERVICE |
String | VIBRATOR_SERVICE |
String | WALLPAPER_SERVICE |
String | WIFI_P2P_SERVICE |
String | WIFI_RTT_SERVICE |
String | WIFI_SCANNING_SERVICE |
String | WIFI_SERVICE |
String | WINDOW_SERVICE |
From interface android.content.ComponentCallbacks2
int | TRIM_MEMORY_BACKGROUND |
int | TRIM_MEMORY_COMPLETE |
int | TRIM_MEMORY_MODERATE |
int | TRIM_MEMORY_RUNNING_CRITICAL |
int | TRIM_MEMORY_RUNNING_LOW |
int | TRIM_MEMORY_RUNNING_MODERATE |
int | TRIM_MEMORY_UI_HIDDEN |

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
void | dump(FileDescriptor arg0, PrintWriter arg1, String[] arg2)
final Application | getApplication()
abstract IBinder | onBind(Intent arg0)
void | onConfigurationChanged(Configuration arg0)
void | onCreate()
void | onDestroy()
void | onLowMemory()
void | onRebind(Intent arg0)
void | onStart(Intent arg0, int arg1)
int | onStartCommand(Intent arg0, int arg1, int arg2)
void | onTaskRemoved(Intent arg0)
void | onTrimMemory(int arg0)
boolean | onUnbind(Intent arg0)
final void | startForeground(int arg0, Notification arg1)
final void | stopForeground(boolean arg0)
final void | stopSelf()
final void | stopSelf(int arg0)
final boolean | stopSelfResult(int arg0)
From class android.content.ContextWrapper
void | attachBaseContext(Context arg0)
boolean | bindService(Intent arg0, ServiceConnection arg1, int arg2)
int | checkCallingOrSelfPermission(String arg0)
int | checkCallingOrSelfUriPermission(Uri arg0, int arg1)
int | checkCallingPermission(String arg0)
int | checkCallingUriPermission(Uri arg0, int arg1)
int | checkPermission(String arg0, int arg1, int arg2)
int | checkUriPermission(Uri arg0, int arg1, int arg2, int arg3)
int | checkUriPermission(Uri arg0, String arg1, String arg2, int arg3, int arg4, int arg5)
void | clearWallpaper()
Context | createConfigurationContext(Configuration arg0)
Context | createDisplayContext(Display arg0)
Context | createPackageContext(String arg0, int arg1)
String[] | databaseList()
boolean | deleteDatabase(String arg0)
boolean | deleteFile(String arg0)
void | enforceCallingOrSelfPermission(String arg0, String arg1)
void | enforceCallingOrSelfUriPermission(Uri arg0, int arg1, String arg2)
void | enforceCallingPermission(String arg0, String arg1)
void | enforceCallingUriPermission(Uri arg0, int arg1, String arg2)
void | enforcePermission(String arg0, int arg1, int arg2, String arg3)
void | enforceUriPermission(Uri arg0, int arg1, int arg2, int arg3, String arg4)
void | enforceUriPermission(Uri arg0, String arg1, String arg2, int arg3, int arg4, int arg5, String arg6)
String[] | fileList()
Context | getApplicationContext()
ApplicationInfo | getApplicationInfo()
AssetManager | getAssets()
Context | getBaseContext()
File | getCacheDir()
ClassLoader | getClassLoader()
File | getCodeCacheDir()
ContentResolver | getContentResolver()
File | getDatabasePath(String arg0)
File | getDir(String arg0, int arg1)
File | getExternalCacheDir()
File[] | getExternalCacheDirs()
File | getExternalFilesDir(String arg0)
File[] | getExternalFilesDirs(String arg0)
File[] | getExternalMediaDirs()
File | getFileStreamPath(String arg0)
File | getFilesDir()
Looper | getMainLooper()
File | getNoBackupFilesDir()
File | getObbDir()
File[] | getObbDirs()
String | getPackageCodePath()
PackageManager | getPackageManager()
String | getPackageName()
String | getPackageResourcePath()
Resources | getResources()
SharedPreferences | getSharedPreferences(String arg0, int arg1)
Object | getSystemService(String arg0)
Resources.Theme | getTheme()
Drawable | getWallpaper()
int | getWallpaperDesiredMinimumHeight()
int | getWallpaperDesiredMinimumWidth()
void | grantUriPermission(String arg0, Uri arg1, int arg2)
boolean | isRestricted()
FileInputStream | openFileInput(String arg0)
FileOutputStream | openFileOutput(String arg0, int arg1)
SQLiteDatabase | openOrCreateDatabase(String arg0, int arg1, SQLiteDatabase.CursorFactory arg2)
SQLiteDatabase | openOrCreateDatabase(String arg0, int arg1, SQLiteDatabase.CursorFactory arg2, DatabaseErrorHandler arg3)
Drawable | peekWallpaper()
Intent | registerReceiver(BroadcastReceiver arg0, IntentFilter arg1)
Intent | registerReceiver(BroadcastReceiver arg0, IntentFilter arg1, String arg2, Handler arg3)
void | removeStickyBroadcast(Intent arg0)
void | removeStickyBroadcastAsUser(Intent arg0, UserHandle arg1)
void | revokeUriPermission(Uri arg0, int arg1)
void | sendBroadcast(Intent arg0)
void | sendBroadcast(Intent arg0, String arg1)
void | sendBroadcastAsUser(Intent arg0, UserHandle arg1)
void | sendBroadcastAsUser(Intent arg0, UserHandle arg1, String arg2)
void | sendOrderedBroadcast(Intent arg0, String arg1, BroadcastReceiver arg2, Handler arg3, int arg4, String arg5, Bundle arg6)
void | sendOrderedBroadcast(Intent arg0, String arg1)
void | sendOrderedBroadcastAsUser(Intent arg0, UserHandle arg1, String arg2, BroadcastReceiver arg3, Handler arg4, int arg5, String arg6, Bundle arg7)
void | sendStickyBroadcast(Intent arg0)
void | sendStickyBroadcastAsUser(Intent arg0, UserHandle arg1)
void | sendStickyOrderedBroadcast(Intent arg0, BroadcastReceiver arg1, Handler arg2, int arg3, String arg4, Bundle arg5)
void | sendStickyOrderedBroadcastAsUser(Intent arg0, UserHandle arg1, BroadcastReceiver arg2, Handler arg3, int arg4, String arg5, Bundle arg6)
void | setTheme(int arg0)
void | setWallpaper(Bitmap arg0)
void | setWallpaper(InputStream arg0)
void | startActivities(Intent[] arg0)
void | startActivities(Intent[] arg0, Bundle arg1)
void | startActivity(Intent arg0)
void | startActivity(Intent arg0, Bundle arg1)
boolean | startInstrumentation(ComponentName arg0, String arg1, Bundle arg2)
void | startIntentSender(IntentSender arg0, Intent arg1, int arg2, int arg3, int arg4, Bundle arg5)
void | startIntentSender(IntentSender arg0, Intent arg1, int arg2, int arg3, int arg4)
ComponentName | startService(Intent arg0)
boolean | stopService(Intent arg0)
void | unbindService(ServiceConnection arg0)
void | unregisterReceiver(BroadcastReceiver arg0)
From class android.content.Context
abstract boolean | bindService(Intent arg0, ServiceConnection arg1, int arg2)
boolean | bindServiceAsUser(Intent arg0, ServiceConnection arg1, int arg2, UserHandle arg3)
abstract int | checkCallingOrSelfPermission(String arg0)
abstract int | checkCallingOrSelfUriPermission(Uri arg0, int arg1)
abstract int | checkCallingPermission(String arg0)
abstract int | checkCallingUriPermission(Uri arg0, int arg1)
abstract int | checkPermission(String arg0, int arg1, int arg2)
abstract int | checkUriPermission(Uri arg0, int arg1, int arg2, int arg3)
abstract int | checkUriPermission(Uri arg0, String arg1, String arg2, int arg3, int arg4, int arg5)
abstract void | clearWallpaper()
abstract Context | createConfigurationContext(Configuration arg0)
abstract Context | createDisplayContext(Display arg0)
abstract Context | createPackageContext(String arg0, int arg1)
abstract String[] | databaseList()
abstract boolean | deleteDatabase(String arg0)
abstract boolean | deleteFile(String arg0)
abstract void | enforceCallingOrSelfPermission(String arg0, String arg1)
abstract void | enforceCallingOrSelfUriPermission(Uri arg0, int arg1, String arg2)
abstract void | enforceCallingPermission(String arg0, String arg1)
abstract void | enforceCallingUriPermission(Uri arg0, int arg1, String arg2)
abstract void | enforcePermission(String arg0, int arg1, int arg2, String arg3)
abstract void | enforceUriPermission(Uri arg0, int arg1, int arg2, int arg3, String arg4)
abstract void | enforceUriPermission(Uri arg0, String arg1, String arg2, int arg3, int arg4, int arg5, String arg6)
abstract String[] | fileList()
abstract Context | getApplicationContext()
abstract ApplicationInfo | getApplicationInfo()
abstract AssetManager | getAssets()
abstract File | getCacheDir()
abstract ClassLoader | getClassLoader()
abstract File | getCodeCacheDir()
abstract ContentResolver | getContentResolver()
abstract File | getDatabasePath(String arg0)
abstract File | getDir(String arg0, int arg1)
final Drawable | getDrawable(int arg0)
abstract File | getExternalCacheDir()
abstract File[] | getExternalCacheDirs()
abstract File | getExternalFilesDir(String arg0)
abstract File[] | getExternalFilesDirs(String arg0)
abstract File[] | getExternalMediaDirs()
abstract File | getFileStreamPath(String arg0)
abstract File | getFilesDir()
abstract Looper | getMainLooper()
abstract File | getNoBackupFilesDir()
abstract File | getObbDir()
abstract File[] | getObbDirs()
abstract String | getPackageCodePath()
abstract PackageManager | getPackageManager()
abstract String | getPackageName()
abstract String | getPackageResourcePath()
abstract Resources | getResources()
abstract SharedPreferences | getSharedPreferences(String arg0, int arg1)
final String | getString(int arg0)
final String | getString(int arg0, Object... arg1)
abstract Object | getSystemService(String arg0)
final CharSequence | getText(int arg0)
abstract Resources.Theme | getTheme()
abstract Drawable | getWallpaper()
abstract int | getWallpaperDesiredMinimumHeight()
abstract int | getWallpaperDesiredMinimumWidth()
abstract void | grantUriPermission(String arg0, Uri arg1, int arg2)
boolean | isRestricted()
final TypedArray | obtainStyledAttributes(int[] arg0)
final TypedArray | obtainStyledAttributes(AttributeSet arg0, int[] arg1, int arg2, int arg3)
final TypedArray | obtainStyledAttributes(AttributeSet arg0, int[] arg1)
final TypedArray | obtainStyledAttributes(int arg0, int[] arg1)
abstract FileInputStream | openFileInput(String arg0)
abstract FileOutputStream | openFileOutput(String arg0, int arg1)
abstract SQLiteDatabase | openOrCreateDatabase(String arg0, int arg1, SQLiteDatabase.CursorFactory arg2)
abstract SQLiteDatabase | openOrCreateDatabase(String arg0, int arg1, SQLiteDatabase.CursorFactory arg2, DatabaseErrorHandler arg3)
abstract Drawable | peekWallpaper()
void | registerComponentCallbacks(ComponentCallbacks arg0)
abstract Intent | registerReceiver(BroadcastReceiver arg0, IntentFilter arg1)
abstract Intent | registerReceiver(BroadcastReceiver arg0, IntentFilter arg1, String arg2, Handler arg3)
abstract void | removeStickyBroadcast(Intent arg0)
abstract void | removeStickyBroadcastAsUser(Intent arg0, UserHandle arg1)
abstract void | revokeUriPermission(Uri arg0, int arg1)
abstract void | sendBroadcast(Intent arg0, String arg1)
abstract void | sendBroadcast(Intent arg0)
abstract void | sendBroadcastAsUser(Intent arg0, UserHandle arg1)
abstract void | sendBroadcastAsUser(Intent arg0, UserHandle arg1, String arg2)
abstract void | sendOrderedBroadcast(Intent arg0, String arg1, BroadcastReceiver arg2, Handler arg3, int arg4, String arg5, Bundle arg6)
abstract void | sendOrderedBroadcast(Intent arg0, String arg1)
abstract void | sendOrderedBroadcastAsUser(Intent arg0, UserHandle arg1, String arg2, BroadcastReceiver arg3, Handler arg4, int arg5, String arg6, Bundle arg7)
abstract void | sendStickyBroadcast(Intent arg0)
abstract void | sendStickyBroadcastAsUser(Intent arg0, UserHandle arg1)
abstract void | sendStickyOrderedBroadcast(Intent arg0, BroadcastReceiver arg1, Handler arg2, int arg3, String arg4, Bundle arg5)
abstract void | sendStickyOrderedBroadcastAsUser(Intent arg0, UserHandle arg1, BroadcastReceiver arg2, Handler arg3, int arg4, String arg5, Bundle arg6)
abstract void | setTheme(int arg0)
abstract void | setWallpaper(InputStream arg0)
abstract void | setWallpaper(Bitmap arg0)
abstract void | startActivities(Intent[] arg0, Bundle arg1)
abstract void | startActivities(Intent[] arg0)
abstract void | startActivity(Intent arg0)
abstract void | startActivity(Intent arg0, Bundle arg1)
abstract boolean | startInstrumentation(ComponentName arg0, String arg1, Bundle arg2)
abstract void | startIntentSender(IntentSender arg0, Intent arg1, int arg2, int arg3, int arg4, Bundle arg5)
abstract void | startIntentSender(IntentSender arg0, Intent arg1, int arg2, int arg3, int arg4)
abstract ComponentName | startService(Intent arg0)
abstract boolean | stopService(Intent arg0)
abstract void | unbindService(ServiceConnection arg0)
void | unregisterComponentCallbacks(ComponentCallbacks arg0)
abstract void | unregisterReceiver(BroadcastReceiver arg0)
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
From interface android.content.ComponentCallbacks2
abstract void | onTrimMemory(int arg0)
From interface com.google.android.gms.wearable.DataApi.DataListener
abstract void | onDataChanged(DataEventBuffer dataEvents) Notification that a set of data items have been changed or deleted.
From interface com.google.android.gms.wearable.MessageApi.MessageListener
abstract void | onMessageReceived(MessageEvent messageEvent) Notification that a message has been received.
From interface com.google.android.gms.wearable.NodeApi.NodeListener
abstract void | onPeerConnected(Node peer) Notification that a peer has been connected.
abstract void | onPeerDisconnected(Node peer) Notification that a peer has been disconnected.
From interface android.content.ComponentCallbacks
abstract void | onConfigurationChanged(Configuration arg0)
abstract void | onLowMemory()

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