GlanceTileService

abstract class GlanceTileService : TileService


TileService which can consume a Glance composition, convert it to a Wear Tile, and provide it to the system. You must implement the Content function to provide your Tile layout, for example:

class MyTile: GlanceTileService() {
@Composable
@GlanceComposable
override fun Content {
Text("Hello World!")
}
}

You must also register ComposeTileService instances in your manifest to allow the system to discover them. Your service must include an intent filter for the action androidx.wear.tiles.action.BIND_TILE_PROVIDER, and require the permission com.google.android.wearable.permission.BIND_TILE_PROVIDER.

Summary

Public constructors

Public functions

abstract Unit

Override this method to set the layout to use in your Tile.

suspend T
<T : Any?> getTileState()

Retrieve the state of the wear tile provided by this service

open IBinder?
onBind(intent: Intent)
open Unit
open Unit
open Unit
onStart(intent: Intent?, startId: Int)

This function is deprecated.

suspend T
<T : Any?> updateTileState(updateState: suspend (T) -> T)

Update the state of the wear tile provided by this service

Protected functions

final ListenableFuture<ResourceBuilders.Resources>

Called by the system to fetch a resources bundle from this GlanceTileService.

open Unit

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

final ListenableFuture<TileBuilders.Tile>

Called by the system to fetch a tile from this GlanceTileService.

Public properties

open GlanceStateDefinition<*>?

Data store for tile data specific to this service

open TimelineMode

Defines the handling of timeline

Inherited functions

From android.content.Context
open Boolean
bindIsolatedService(
    service: Intent,
    flags: Context.BindServiceFlags,
    instanceName: String,
    executor: Executor,
    conn: ServiceConnection
)
Int
ColorStateList
Drawable?
String
getString(resId: Int)
String
getString(resId: Int, vararg formatArgs: Any)
T
<T : Any> getSystemService(serviceClass: Class<T>)
CharSequence
getText(resId: Int)
TypedArray
TypedArray
TypedArray
TypedArray
obtainStyledAttributes(
    set: AttributeSet?,
    attrs: IntArray,
    defStyleAttr: Int,
    defStyleRes: Int
)
open Unit
open Unit
sendBroadcastWithMultiplePermissions(
    intent: Intent,
    receiverPermissions: Array<String>
)
From android.content.ContextWrapper
open Boolean
bindIsolatedService(
    p0: Intent,
    p1: Int,
    p2: String,
    p3: Executor,
    p4: ServiceConnection
)
open Boolean
bindService(
    p0: Intent,
    p1: ServiceConnection,
    p2: Context.BindServiceFlags
)
open Boolean
open Boolean
bindService(
    p0: Intent,
    p1: Context.BindServiceFlags,
    p2: Executor,
    p3: ServiceConnection
)
open Boolean
bindService(p0: Intent, p1: Int, p2: Executor, p3: ServiceConnection)
open Boolean
bindServiceAsUser(
    p0: Intent,
    p1: ServiceConnection,
    p2: Context.BindServiceFlags,
    p3: UserHandle
)
open Boolean
open Int
open Int
open IntArray
open Int
open Int
open IntArray
open Int
checkPermission(p0: String, p1: Int, p2: Int)
open Int
open Int
checkUriPermission(p0: Uri, p1: Int, p2: Int, p3: Int)
open Int
checkUriPermission(p0: Uri?, p1: String?, p2: String?, p3: Int, p4: Int, p5: Int)
open IntArray
checkUriPermissions(p0: MutableList<Uri>, p1: Int, p2: Int, p3: Int)
open Unit

This function is deprecated.

open Context
open Context
open Context
open Context
open Context
open Context
open Context
open Context
open Context
open Context
createWindowContext(p0: Display, p1: Int, p2: Bundle?)
open Array<String>
open Boolean
open Boolean
open Boolean
open Unit
open Unit
open Unit
open Unit
open Unit
enforcePermission(p0: String, p1: Int, p2: Int, p3: String?)
open Unit
enforceUriPermission(p0: Uri, p1: Int, p2: Int, p3: Int, p4: String)
open Unit
enforceUriPermission(
    p0: Uri?,
    p1: String?,
    p2: String?,
    p3: Int,
    p4: Int,
    p5: Int,
    p6: String?
)
open Array<String>
open Context
open ApplicationInfo
open AssetManager
open AttributionSource
open String?
open Context
open File
open ClassLoader
open File
open ContentResolver
open File
open File
open Int
open File
getDir(p0: String, p1: Int)
open Display?
open File?
open Array<File>
open File?
open Array<File>
open Array<File>

This function is deprecated.

open File
open File
open Executor
open Looper
open File
open File
open Array<File>
open String
open String
open PackageManager
open String
open String
open ContextParams?
open Resources
open SharedPreferences
open Any
open String?
open Resources.Theme
open Drawable

This function is deprecated.

open Int

This function is deprecated.

open Int

This function is deprecated.

open Unit
grantUriPermission(p0: String, p1: Uri, p2: Int)
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open FileInputStream
open FileOutputStream
open SQLiteDatabase
open SQLiteDatabase
openOrCreateDatabase(
    p0: String,
    p1: Int,
    p2: SQLiteDatabase.CursorFactory,
    p3: DatabaseErrorHandler?
)
open Drawable

This function is deprecated.

open Unit
open Unit
open Intent?
open Intent?
open Intent?
registerReceiver(
    p0: BroadcastReceiver?,
    p1: IntentFilter,
    p2: String?,
    p3: Handler?
)
open Intent?
registerReceiver(
    p0: BroadcastReceiver?,
    p1: IntentFilter,
    p2: String?,
    p3: Handler?,
    p4: Int
)
open Unit

This function is deprecated.

open Unit

This function is deprecated.

open Unit
open Unit
open Unit
revokeUriPermission(p0: String, p1: Uri, p2: Int)
open Unit
open Unit
open Unit
sendBroadcast(p0: Intent, p1: String?, p2: Bundle?)
open Unit
open Unit
open Unit
open Unit
open Unit
sendOrderedBroadcast(
    p0: Intent,
    p1: String?,
    p2: BroadcastReceiver?,
    p3: Handler?,
    p4: Int,
    p5: String?,
    p6: Bundle?
)
open Unit
sendOrderedBroadcast(
    p0: Intent,
    p1: String?,
    p2: Bundle?,
    p3: BroadcastReceiver?,
    p4: Handler?,
    p5: Int,
    p6: String?,
    p7: Bundle?
)
open Unit
sendOrderedBroadcast(
    p0: Intent,
    p1: String?,
    p2: String?,
    p3: BroadcastReceiver?,
    p4: Handler?,
    p5: Int,
    p6: String?,
    p7: Bundle?
)
open Unit
sendOrderedBroadcast(
    p0: Intent,
    p1: Int,
    p2: String?,
    p3: String?,
    p4: BroadcastReceiver?,
    p5: Handler?,
    p6: String?,
    p7: Bundle?,
    p8: Bundle?
)
open Unit
sendOrderedBroadcastAsUser(
    p0: Intent,
    p1: UserHandle,
    p2: String?,
    p3: BroadcastReceiver?,
    p4: Handler?,
    p5: Int,
    p6: String?,
    p7: Bundle?
)
open Unit

This function is deprecated.

open Unit

This function is deprecated.

open Unit

This function is deprecated.

open Unit
sendStickyOrderedBroadcast(
    p0: Intent,
    p1: BroadcastReceiver?,
    p2: Handler?,
    p3: Int,
    p4: String?,
    p5: Bundle?
)

This function is deprecated.

open Unit
sendStickyOrderedBroadcastAsUser(
    p0: Intent,
    p1: UserHandle,
    p2: BroadcastReceiver?,
    p3: Handler?,
    p4: Int,
    p5: String?,
    p6: Bundle?
)

This function is deprecated.

open Unit
open Unit

This function is deprecated.

open Unit

This function is deprecated.

open Unit
open Unit
open Unit
open Unit
open ComponentName?
open Boolean
open Unit
startIntentSender(p0: IntentSender, p1: Intent?, p2: Int, p3: Int, p4: Int)
open Unit
startIntentSender(
    p0: IntentSender,
    p1: Intent?,
    p2: Int,
    p3: Int,
    p4: Int,
    p5: Bundle?
)
open ComponentName?
open Boolean
open Unit
open Unit
open Unit
open Unit
open Unit
From android.app.Service
open Unit
open Unit
dump(fd: FileDescriptor, writer: PrintWriter, args: Array<String>)
Application
Int
open Unit
open Unit
open Unit
onRebind(intent: Intent)
open Int
onStartCommand(intent: Intent, flags: Int, startId: Int)
open Unit
onTaskRemoved(rootIntent: Intent)
open Unit
onTimeout(startId: Int)
open Unit
onTrimMemory(level: Int)
open Boolean
onUnbind(intent: Intent)
Unit
startForeground(id: Int, notification: Notification)
Unit
startForeground(
    id: Int,
    notification: Notification,
    foregroundServiceType: Int
)
Unit
stopForeground(notificationBehavior: Int)
Unit
stopForeground(removeNotification: Boolean)

This function is deprecated.

Unit
Unit
stopSelf(startId: Int)
Boolean
stopSelfResult(startId: Int)
From androidx.wear.tiles.TileService
open Unit

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

open Unit

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

open Unit

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

open ListenableFuture<ResourceBuilders.Resources>

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

Public constructors

GlanceTileService

Added in 1.0.0-alpha06
GlanceTileService(
    errorUiLayout: LayoutElementBuilders.LayoutElement? = errorUiLayout()
)
Parameters
errorUiLayout: LayoutElementBuilders.LayoutElement? = errorUiLayout()

If not null and an error occurs within this glance wear tile, the tile is updated with an error UI using the provided layout.

Public functions

Content

Added in 1.0.0-alpha06
@Composable
@GlanceComposable
abstract fun Content(): Unit

Override this method to set the layout to use in your Tile.

getTileState

suspend fun <T : Any?> getTileState(): T

Retrieve the state of the wear tile provided by this service

onBind

open fun onBind(intent: Intent): IBinder?

onCreate

open fun onCreate(): Unit

onDestroy

open fun onDestroy(): Unit

onStart

Added in 1.0.0-alpha06
open fun onStart(intent: Intent?, startId: Int): Unit

updateTileState

suspend fun <T : Any?> updateTileState(updateState: suspend (T) -> T): T

Update the state of the wear tile provided by this service

Protected functions

onResourcesRequest

Added in 1.0.0-alpha06
protected final fun onResourcesRequest(requestParams: RequestBuilders.ResourcesRequest): ListenableFuture<ResourceBuilders.Resources>

Called by the system to fetch a resources bundle from this GlanceTileService.

Note that this call exists due to this class extending TileService; this should not be called directly.

onTileRemoveEvent

@CallSuper
protected open 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 TileRemoveEvent for more info.

onTileRequest

Added in 1.0.0-alpha06
protected final fun onTileRequest(requestParams: RequestBuilders.TileRequest): ListenableFuture<TileBuilders.Tile>

Called by the system to fetch a tile from this GlanceTileService.

Note that this call exists due to this class extending TileService; this should not be called directly.

Public properties

stateDefinition

Added in 1.0.0-alpha06
open val stateDefinitionGlanceStateDefinition<*>?

Data store for tile data specific to this service

timelineMode

Added in 1.0.0-alpha06
open val timelineModeTimelineMode

Defines the handling of timeline