TileService
abstract class TileService : Service
| kotlin.Any | ||||
| ↳ | android.content.Context | |||
| ↳ | android.content.ContextWrapper | |||
| ↳ | android.app.Service | |||
| ↳ | androidx.wear.tiles.TileService |
GlanceTileService |
This class is deprecated. glance-wear-tiles is deprecated and will be removed |
Base class for a service providing data for an app tile.
A provider service must implement onTileRequest and onTileResourcesRequest 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 |
|
|---|---|
const String! |
ACTION_BIND_TILE_PROVIDER = "androidx.wear.tiles.action.BIND_TILE_PROVIDER"The intent action used to send update requests to the provider. |
const String! |
EXTRA_CLICKABLE_ID = "androidx.wear.tiles.extra.CLICKABLE_ID"The ID for the Intent extra containing the ID of the Clickable. |
const String! |
METADATA_PREVIEW_KEY = "androidx.wear.tiles.PREVIEW"The name of the metadata key that should contain a drawable to be presented as a Tile preview. |
Public constructors |
|---|
Public functions |
|
|---|---|
java-static ListenableFuture<(Mutable)List<ActiveTileIdentifier!>!> |
getActiveTilesAsync(context: Context, executor: Executor)Returns the list of active tiles belonging to the passed |
java-static TileUpdateRequester |
getUpdater(context: Context)Gets an instance of |
IBinder? |
Protected functions |
|
|---|---|
ListenableFuture<Void!> |
@MainThreadCalled when the system sends a batch of Tile interaction events that happened since the last time this method was called. |
ListenableFuture<ResourceBuilders.Resources!> |
@MainThreadThis function is deprecated. Use |
Unit |
@MainThreadCalled when a tile provided by this Tile Provider is added to the carousel. |
Unit |
@MainThreadThis function is deprecated. |
Unit |
@MainThreadThis function is deprecated. |
Unit |
@MainThreadCalled when a tile provided by this Tile Provider is removed from the carousel. |
abstract ListenableFuture<TileBuilders.Tile!> |
@MainThreadCalled when the system is requesting a new timeline from this Tile Provider. |
ListenableFuture<ResourceBuilders.Resources!> |
@MainThreadCalled when the system is requesting a resource bundle from this Tile Provider. |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Constants
ACTION_BIND_TILE_PROVIDER
const val ACTION_BIND_TILE_PROVIDER = "androidx.wear.tiles.action.BIND_TILE_PROVIDER": String!
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.
EXTRA_CLICKABLE_ID
const val EXTRA_CLICKABLE_ID = "androidx.wear.tiles.extra.CLICKABLE_ID": String!
The ID for the Intent extra containing the ID of the Clickable.
METADATA_PREVIEW_KEY
const val METADATA_PREVIEW_KEY = "androidx.wear.tiles.PREVIEW": String!
The name of the metadata key that should contain a drawable to be presented as a Tile preview.
Public constructors
Public functions
getActiveTilesAsync
java-static fun getActiveTilesAsync(context: Context, executor: Executor): ListenableFuture<(Mutable)List<ActiveTileIdentifier!>!>
Returns the list of active tiles belonging to the passed context's package name. A tile is considered to be active if it is present in the carousel.
The result reflects the state of carousel at the time the call was made, which might've changed by the time the result is received. onTileAddEvent and onTileRemoveEvent should be used instead for live updates.
Compatibility behavior:
On SDKs older than U, this method is a best-effort to match platform behavior, but may not always return all tiles present in the carousel. The possibly omitted tiles being the pre-installed tiles, all tiles if the user has cleared the app data, or the tiles a user hasn't visited in the last 60 days, while tiles removed by an app update may be shown as active for 60 days afterwards.
| Parameters | |
|---|---|
context: Context |
The application context. |
executor: Executor |
The executor on which methods should be invoked. To dispatch events through the main thread of your application, you can use |
| Returns | |
|---|---|
ListenableFuture<(Mutable)List<ActiveTileIdentifier!>!> |
A list of |
getUpdater
java-static fun getUpdater(context: Context): TileUpdateRequester
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 TileService.
| Parameters | |
|---|---|
context: Context |
The application context. |
Protected functions
onRecentInteractionEventsAsync
@MainThread
protected fun onRecentInteractionEventsAsync(
events: (Mutable)List<EventBuilders.TileInteractionEvent!>
): ListenableFuture<Void!>
Called when the system sends a batch of Tile interaction events that happened since the last time this method was called. The time between calls to this method may vary, do not depend on it for time-sensitive or critical tasks.
Interaction events represent user direct interaction with a tile, when a tile comes into view (enter event) or when the tiles goes out of view (leave event).
The returned future must complete after at most 10 seconds from the moment this method is called (exact timeout length subject to change, but 10 seconds is guaranteed).
This method is called from your app's main thread, which is usually also the UI thread.
| Parameters | |
|---|---|
events: (Mutable)List<EventBuilders.TileInteractionEvent!> |
A list of |
@MainThread
protected funonResourcesRequest(requestParams: RequestBuilders.ResourcesRequest): ListenableFuture<ResourceBuilders.Resources!>
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: RequestBuilders.ResourcesRequest |
Parameters about the request. See |
onTileAddEvent
@MainThread
protected fun onTileAddEvent(requestParams: EventBuilders.TileAddEvent): Unit
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: EventBuilders.TileAddEvent |
Parameters about the request. See |
@MainThread
protected funonTileEnterEvent(requestParams: EventBuilders.TileEnterEvent): Unit
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: EventBuilders.TileEnterEvent |
Parameters about the request. See |
@MainThread
protected funonTileLeaveEvent(requestParams: EventBuilders.TileLeaveEvent): Unit
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: EventBuilders.TileLeaveEvent |
Parameters about the request. See |
onTileRemoveEvent
@MainThread
protected fun onTileRemoveEvent(requestParams: EventBuilders.TileRemoveEvent): Unit
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: EventBuilders.TileRemoveEvent |
Parameters about the request. See |
onTileRequest
@MainThread
protected abstract fun onTileRequest(requestParams: RequestBuilders.TileRequest): ListenableFuture<TileBuilders.Tile!>
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: RequestBuilders.TileRequest |
Parameters about the request. See |
onTileResourcesRequest
@MainThread
protected fun onTileResourcesRequest(requestParams: RequestBuilders.ResourcesRequest): ListenableFuture<ResourceBuilders.Resources!>
Called when the system is requesting a resource bundle from this Tile Provider. This can happen on the first time a Tile is being loaded or whenever the resource version requested by a Tile (in onTileRequest) changes.
If using methods that accept ProtoLayoutScope for creating image elements, this method shouldn't be implemented as resources bundle will be automatically registered by the ProtoLayoutScope itself.
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.
If onTileResourcesRequest is not implemented, the TileService will fallback to onResourcesRequest.
| Parameters | |
|---|---|
requestParams: RequestBuilders.ResourcesRequest |
Parameters about the request. See |