Reputation: 61
I found a way that use try catch with PeerFinder.FindAllPeersAsync()
But I don't know is bluetooth hardware doesn't exist or bluetooth closed.
How to know difference?
Upvotes: 0
Views: 393
Reputation: 5636
According to MSDN, you can determine bluetooth is off by checking the HResult
of an exception caught when calling PeerFinder.FindAllPeersAsync()
. They provide the following example code:
try
{
var peers = await PeerFinder.FindAllPeersAsync();
// Handle the result of the FindAllPeersAsync call
}
catch (Exception ex)
{
if ((uint)ex.HResult == 0x8007048F)
{
MessageBox.Show("Bluetooth is turned off");
}
}
To detect device capabilities, look into the PeerFinder.SupportedDiscoveryTypes property.
Upvotes: 2