获取BandAccessDeniedException从BackgroundTask
问题描述:
的Windows Phone 8.1(商店)的应用程序,MS带SDK v1.3.20217获取BandAccessDeniedException从BackgroundTask
前台应用程序的伟大工程,作为一个用户,我有权访问交谈的乐队有问题。我得到的地方,我
client = await BandClientManager.Instance.ConnectAsync(band);
点,我会见了
Microsoft.Band.BandAccessDeniedException occurred
Message: Exception thrown: 'Microsoft.Band.BandAccessDeniedException' in Microsoft.Band.Store.DLL
Additional information: A non-specific error occurred while attempting to acquire the Bluetooth device service. This error can occur if the application manifest does not have the required permissions for opening the Bluetooth connection to the Microsoft Band, or if the user denies access.
虽然我的应用程序清单有:
<Capabilities>
<Capability Name="internetClientServer" />
<DeviceCapability Name="proximity" />
<DeviceCapability Name="bluetooth.rfcomm" xmlns="http://schemas.microsoft.com/appx/2013/manifest">
<Device Id="any">
<!-- Used by the Microsoft Band SDK -->
<Function Type="serviceId:A502CA9A-2BA5-413C-A4E0-13804E47B38F" />
<!-- Used by the Microsoft Band SDK -->
<Function Type="serviceId:C742E1A2-6320-5ABC-9643-D206C677E580" />
</Device>
</DeviceCapability>
</Capabilities>
当我从一开始的目标区间客户经理,我正在做:
var bands = await BandClientManager.Instance.GetBandsAsync(true);
band = bands.FirstOrDefault(b => b.Name == targetBandName);
so我表示这是从背景开始,它成功地给了我一个Microsoft.Band.Store.BluetoothDeviceInfo
实例投入ConnectAsync
任何想法是怎么回事?
答
如果我将GetBandsAsync(true)
更改为GetBandsAsync()
,则此问题消失。它似乎有一个错误在ConnectAsync
当BluetoothDeviceInfo
例如,从GetBandsAsync(true)
答
愚蠢的答案出来,但如果任何人发现这是我通过冰做的:
从2.3.1 SDK文档:“应用程序将需要以声明访问蓝牙硬件资源所需的适当权限,为此,请手动更新应用程序的Package.appxmanifest文件的Capabilities部分,以包含以下“
...基本上,这是一个复选框Package.appxmanifest功能选项卡。是的,这很明显,但我没有意识到。 HTH某人。
注意:这与b3tech看到的问题是正交的,但表现出相同的问题。