TileProviderService

public abstract class TileProviderService
extends Service

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ androidx.wear.tiles.TileProviderService


Base class for a service providing data for an app tile.

A provider service must implement onTileRequest(RequestReaders.TileRequest) and onResourcesRequest(RequestReaders.ResourcesRequest) to respond to requests for updates from the system.

The manifest declaration of this service must include an intent filter for ACTION_BIND_TILE_PROVIDER.

The manifest entry should also include android:permission="com.google.android.wearable.permission.BIND_TILE_PROVIDER" to ensure that only the system can bind to it.

Summary

Constants

String ACTION_BIND_TILE_PROVIDER

The intent action used to send update requests to the provider.

String EXTRA_CLICKABLE_ID

The ID for the Intent extra containing the ID of the Clickable.

String METADATA_PREVIEW_KEY

The name of the metadata key that should contain a drawable to be presented as a Tile preview.

Inherited constants

Public constructors

TileProviderService()

Public methods

static TileUpdateRequester getUpdater(Context context)

Gets an instance of TileUpdateRequester to allow a Tile Provider to notify the tile's renderer that it should request a new Timeline from this TileProviderService.

IBinder onBind(Intent intent)

Protected methods

abstract ListenableFuture<ResourceBuilders.Resources> onResourcesRequest(RequestReaders.ResourcesRequest requestParams)

Called when the system is requesting a resource bundle from this Tile Provider.

void onTileAddEvent(EventReaders.TileAddEvent requestParams)

Called when a tile provided by this Tile Provider is added to the carousel.

void onTileEnterEvent(EventReaders.TileEnterEvent requestParams)

Called when a tile provided by this Tile Provider becomes into view, on screen.

void onTileLeaveEvent(EventReaders.TileLeaveEvent requestParams)

Called when a tile provided by this Tile Provider goes out of view, on screen.

void onTileRemoveEvent(EventReaders.TileRemoveEvent requestParams)

Called when a tile provided by this Tile Provider is removed from the carousel.

abstract ListenableFuture<TileBuilders.Tile> onTileRequest(RequestReaders.TileRequest requestParams)

Called when the system is requesting a new timeline from this Tile Provider.

Inherited methods

Constants

ACTION_BIND_TILE_PROVIDER

public static final String ACTION_BIND_TILE_PROVIDER

The intent action used to send update requests to the provider. Tile provider services must declare an intent filter for this action in the manifest.

Constant Value: "androidx.wear.tiles.action.BIND_TILE_PROVIDER"

EXTRA_CLICKABLE_ID

public static final String EXTRA_CLICKABLE_ID

The ID for the Intent extra containing the ID of the Clickable.

Constant Value: "androidx.wear.tiles.extra.CLICKABLE_ID"

METADATA_PREVIEW_KEY

public static final String METADATA_PREVIEW_KEY

The name of the metadata key that should contain a drawable to be presented as a Tile preview.

Constant Value: "androidx.wear.tiles.PREVIEW"

Public constructors

TileProviderService

public TileProviderService ()

Public methods

getUpdater

public static TileUpdateRequester getUpdater (Context context)

Gets an instance of TileUpdateRequester to allow a Tile Provider to notify the tile's renderer that it should request a new Timeline from this TileProviderService.

Parameters
context Context: The application context.

Returns
TileUpdateRequester

onBind

public IBinder onBind (Intent intent)

Parameters
intent Intent

Returns
IBinder

Protected methods

onResourcesRequest

protected abstract ListenableFuture<ResourceBuilders.Resources> onResourcesRequest (RequestReaders.ResourcesRequest requestParams)

Called when the system is requesting a resource bundle from this Tile Provider. The returned future must complete after at most 10 seconds from the moment this method is called (exact timeout length subject to change).

Note that this is called from your app's main thread, which is usually also the UI thread.

Parameters
requestParams RequestReaders.ResourcesRequest: Parameters about the request. See RequestReaders.ResourcesRequest for more info.

Returns
ListenableFuture<ResourceBuilders.Resources>

onTileAddEvent

protected void onTileAddEvent (EventReaders.TileAddEvent requestParams)

Called when a tile provided by this Tile Provider is added to the carousel.

Note that this is called from your app's main thread, which is usually also the UI thread.

Parameters
requestParams EventReaders.TileAddEvent: Parameters about the request. See EventReaders.TileAddEvent for more info.

onTileEnterEvent

protected void onTileEnterEvent (EventReaders.TileEnterEvent requestParams)

Called when a tile provided by this Tile Provider becomes into view, on screen.

Note that this is called from your app's main thread, which is usually also the UI thread.

Parameters
requestParams EventReaders.TileEnterEvent: Parameters about the request. See EventReaders.TileEnterEvent for more info.

onTileLeaveEvent

protected void onTileLeaveEvent (EventReaders.TileLeaveEvent requestParams)

Called when a tile provided by this Tile Provider goes out of view, on screen.

Note that this is called from your app's main thread, which is usually also the UI thread.

Parameters
requestParams EventReaders.TileLeaveEvent: Parameters about the request. See EventReaders.TileLeaveEvent for more info.

onTileRemoveEvent

protected void onTileRemoveEvent (EventReaders.TileRemoveEvent requestParams)

Called when a tile provided by this Tile Provider is removed from the carousel.

Note that this is called from your app's main thread, which is usually also the UI thread.

Parameters
requestParams EventReaders.TileRemoveEvent: Parameters about the request. See EventReaders.TileRemoveEvent for more info.

onTileRequest

protected abstract ListenableFuture<TileBuilders.Tile> onTileRequest (RequestReaders.TileRequest requestParams)

Called when the system is requesting a new timeline from this Tile Provider. The returned future must complete after at most 10 seconds from the moment this method is called (exact timeout length subject to change).

Note that this is called from your app's main thread, which is usually also the UI thread.

Parameters
requestParams RequestReaders.TileRequest: Parameters about the request. See RequestReaders.TileRequest for more info.

Returns
ListenableFuture<TileBuilders.Tile>