Wear TileService Lifecycle

211 views Asked by At

I have created a TileService for watch app. When i switch to my TileService every time onCreate method is called multiple times (3 or 4 times).

As TileService is a Service why onCreate is called multiple times?

And when I switch to my TileService by swiping it doesn't call onTileRequest for every onCreate to update UI.

From official doc onTileRequest called every time user have a action on UI.

Can anyone explain me the lifecycle of TileService .

How can i update Tile UI every time onCreate is called ?

I need latest UI when user switch to the Tile by swiping.

1

There are 1 answers

0
Michael On

Try using onTileEnterEvent. It's called every time the tile is visible.

A simple example that causes the Tile to render a new UI.

override fun onTileEnterEvent(requestParams: EventBuilders.TileEnterEvent){

TileService.getUpdater(this)
            .requestUpdate(MyTileService::class.java)
}