Reputation: 873
I'm trying to interact with Band just after user tap on a Band's tile. But I cannot figure out, how to do this. With this code, followed by guide on developers.microsoftband.com I have nothing. When I tap on a tile, nothing happens...
Here's a code:
using Microsoft.Band;
using Microsoft.Band.Tiles;
using Microsoft.Band.Tiles.Pages;
using (IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0]))
{
//creating tile here
//...
if (await bandClient.TileManager.AddTileAsync(tile))
{
bandClient.TileManager.TileOpened += (sender, ev) =>
{
System.Diagnostics.Debug.WriteLine("Opened");
System.Diagnostics.Debug.WriteLine(ev.TileEvent.TileId);
};
await bandClient.TileManager.StartReadingsAsync();
}
}
Upvotes: 1
Views: 167
Reputation: 2016
In order to receive Tile events from the Band, you have to maintain a connection to the Band during the time period of interest. In your sample code, you use a 'using' statement/block to manage the connection to the Band, but the block ends immediately after starting readings from the Band. This effectively closes the connection to the Band right after you starting listening for Tile events, which is likely why you never receive any.
To receive events from the Band, do not dispose of the IBandClient until the period of time in which you're interested in events has elapsed.
Upvotes: 1