sunjinbo
sunjinbo

Reputation: 2187

How can I know bluetooth is enabled or not on Windows phone 8?

I can use ConnectionSettingsTask to access Bluetooth settings, but how can I know whether Bluetooth's enabled after the task is completed?

I checked windows phone marketplace, found that some app can do that, for example:

http://www.windowsphone.com/en-us/store/app/quick-settings/2a2cbaa7-6d75-420c-ae14-2339618da43e

Thanks!

Upvotes: 2

Views: 2188

Answers (1)

Swift Sharp
Swift Sharp

Reputation: 2623

It's just a suggestion,this is what i am using, i am sure that there are better ways

 private async void FindPaired()
    {
        Windows.Networking.Proximity.PeerFinder.Start();
        try
        {
            var peers = await Windows.Networking.Proximity.PeerFinder.FindAllPeersAsync();
            bth = true; //boolean variable
        }
        catch (Exception ex)
        {
            if ((uint)ex.HResult == 0x8007048F)
            {
                bth = false;
            }
           
        }          
    }

An error 0x8007048F indicated if Bluetooth is turned off. This is working for me without any problems. For more information visit this link

Good luck mate (:

Upvotes: 2

Related Questions