The Android TileService documentation states the following:
When a tile should be up to date and listing will be indicated by onStartListening() and onStopListening().
Based on the lifecycle for a TileService, it's intended that you START updating your tiles state when onStartListening()
is called.
The issue is that it doesn't seem that this callback is called immediately when the tile enters the users view. Meaning it can show outdated information for several seconds some times before the view is properly updated.
An example of this would be that a service is Connected, the tile shows it as connected. I then switch to the application, turn off the service, then open the Quick Settings view back up. It still shows the service as connected for a long time.
In theory, the moment that the tile came into view it should have updated with the new data and displayed it as not connected.
I've confirmed this is the case by simply adding a log message as the first entry in the view. When I bring the Tile into the users view, that log message isn't written to log cat for upwards of 4-5 seconds.
So, what's going on? Am I missing something?
My Code
@Override
public void onStartListening() {
android.util.Log.d("Test", "onStartListening called");
updateTileDisplay();
registerDelegate();
}
The updateTileDisplay();
function is updating the title, state and icon for the Tile. Once it completes it is calling tile.updateTile();
as it should be. Additionally, the registerDelegate();
function is registering a delegate that will listen for internal state changes and update the tile accordingly. This delegate is later removed when onStopListening()
is called.
I do not see that onStartListening called
log message until upwards of 5 seconds after I have brought my tile into view. This seems not to line up with the TileService documentation.