我尝试从 Windows Phone 8.1(SDK 从 2015 年 7 月开始)将新磁贴添加到 Microsoft Band,
但是当我添加新瓷砖(通过下面包含的代码)时,我得到了允许第三方瓷砖的对话框。在此对话框同步带后并且在我收到此异常后:
{Microsoft.Band.BandIOException:无法连接到目标频段。---> System.AggregateException:发生一个或多个错误。---> System.Exception:每个套接字地址(协议/网络地址/端口)通常只允许使用一次。每个套接字地址(协议/网络地址/端口)通常只允许使用一次。--- 内部异常堆栈跟踪的结束 --- 在 System.Threading.Tasks.Task.Wait(Int32 毫秒超时,CancellationToken cancelToken) 在 System.Threading.Tasks 的 System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)。 Task.Wait() at Microsoft.Band.Store.BluetoothTransportBase.Connect(RfcommDeviceService service, UInt16 maxConnectAttempts) --- 内部异常堆栈跟踪结束 --- ...
带代码:
using (IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0]))
{
try
{
IEnumerable<BandTile> tiles = await bandClient.TileManager.GetTilesAsync();
foreach (var t in tiles)
{
if (await bandClient.TileManager.RemoveTileAsync(t))
{
}
}
var remaining = await bandClient.TileManager.GetRemainingTileCapacityAsync();
if (remaining == 0)
{
return;
}
Guid tileGuid = Guid.NewGuid();
BandTile tile = new BandTile(tileGuid)
{
Name = "BandTestTile",
SmallIcon = smallIcon,
TileIcon = tileIcon,
};
await bandClient.TileManager.AddTileAsync(tile);
await bandClient.NotificationManager.ShowDialogAsync(tileGuid, "Hello", "Hello world!");
Guid messagesPageGuid = Guid.NewGuid();
PageData pageContent = new PageData(
messagesPageGuid,
0,
new WrappedTextBlockData(
(Int16)TileMessagesLayoutElementId.Message1,
"This is the text of the first message"),
new WrappedTextBlockData(
(Int16)TileMessagesLayoutElementId.Message2,
"This is the text of the second message")
);
await bandClient.TileManager.SetPagesAsync(tileGuid, pageContent);
}
catch (BandException ex)
{
}
}
你有什么想法,有什么问题?