Friday, April 1, 2011

Windows Phone 7 – Quick Tip #26 – Detect Connection to Zune

If you are building an application that needs to access any of the media libraries, you know you can’t do so when your Windows Phone 7 device is connected to the Zune Desktop application.  This is a real bummer when you are developing you application.  If you’ve done this a lot you know you can get around this with WPConnect but that doesn’t help after you have deployed your application and your users have they phone connected to the Zune software.

Although you can’t really do much to fix this issue, you can improve the UX of your app.  Right now if you launch something like a picture chooser, it will just fail silently, it won’t crash, but it won’t be shown either.  Here’s a relatively simple way you can see if the Zune Desktop is connected:

if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType == 

    /*Sorry, you are probably connected to zune and your chooser won’t launch */

    /* You are probably good to go and you can launch a chooser */

What I do is just display a simple message box that says to use this feature please disconnect your phone from the computer (or something like that).


No comments:

Post a Comment