MS Band SDK - Button pressed event handler not being called

隐身守侯 提交于 2019-12-06 09:06:19

You can only receive events from the Band while you have an active IBandClient instance (i.e. an active connection to the Band). In your code above, the bandClient instance is disposed of immediately after StartReadingsAsync() is called, due to the use of the using() {} block. When an IBandClient instance is disposed, it causes the application to disconnect from the Band.

You need to hold onto the IBandClient instance for the length of time during which you wish to receive events, and dispose of the instance only after that time.

This is great to see someone developing on the MS Band.... heres a few links that discuss the OnConnectToBand and its setup

void EventHandler_TileButtonPressed(object sender,
BandTileEventArgs<IBandTileButtonPressedEvent> e)
{
 // This method is called when the user presses the
 // button in our tile’s layout.
 //
 // e.TileEvent.TileId is the tile’s Guid.
 // e.TileEvent.Timestamp is the DateTimeOffset of the event.
 // e.TileEvent.PageId is the Guid of our page with the button.
 // e.TileEvent.ElementId is the value assigned to the button
 // in our layout (i.e.,
 // TilePageElementId.Button_PushMe).
 //
 // handle the event
 }

Section 9- Handling custom events http://developer.microsoftband.com/Content/docs/Microsoft%20Band%20SDK.pdf

Talks about adding, clicking, removing tiles http://www.jayway.com/2015/03/04/first-impression-of-microsoft-band-developing-2/

Try adding a dialog(below is windows code, for ios or android have a look at the above mentioned manual) to respond to the event (in your code above there is nothing in your event handler? this to see if it actually does something?

using Microsoft.Band.Notifications;

try
{
 // send a dialog to the Band for one of our tiles
 await bandClient.NotificationManager.ShowDialogAsync(tileGuid,
"Dialog title", "Dialog body");
}
catch (BandException ex)
{
// handle a Band connection exception
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!