FMRadio will be back in Windows Phone 8 GDR2: Use it with care!

When we look at what’s new in the GDR2, we will be served with the FMRadio API again. The API itself wasn’t gone really, only the implementation does fire exceptions. But we know we can use the FMRadio again from GDR2. How could we write code that doesn’t fail because of this?

So we need to know the version number from which the GDR2 release starts to be able to write code that checks the version number against the GDR2 release version number.

When we look at the Windows Phone 8 update history, we actually see two version numbers for the GDR2 release. The version number depends on the specific phone model and mobile operator, it could be either 8.0.10327.77 or 8.0.10328.78. My guess is to only check against the lowest version number of the two. However the SDK emulator update for GDR2 shows a different version number 8.0.10322.0. So I better use that lower version number so you can use the emulator. So before you try to use the FMRadio in your Windows Phone 8 app, check if the API is even supported. Besides it can still happen that your phone doesn’t even support FMRadio (which is the case for the emulator (as far as I know).

Hope this code helps you when you want to write code against the FMRadio in a Windows Phone 8 app.

var gdr2Version = new Version(8,0,10322,0);
FMRadio radioInstance = null;
if (Environment.OSVersion.Version >= gdr2Version)
{
    try
    {
        radioInstance = FMRadio.Instance;
    }
    catch (RadioDisabledException)
    {
        radioInstance = null;
    }
}
if (radioInstance != null)
{
    //Do the operations you want to do on the Radio Instance.
}

 

Update August 12th:

Pedro Lamas, wrote an excellent article which is related: FMRadio vs. BackgroundAudioPlayer... fight!!

Basically, even if you’re not using the FMRadio directly, you should be aware of a problem that exists in the GDR2 update which affect all apps that use audio, whether it’s using the BackgroundAudioPlayer or just simply a MediaElement. Read Pedro’s article for the details.

Development made easier for Apps that need some setup

Some of the apps I had didn’t need much setup, but some of them did. For example in my the Podcast app I created, P | Cast, I need to have some subscriptions and downloaded tracks. You of course don’t want to search for podcasts, add as subscription and wait for the tracks to download before you can continue to test/dev.

You are lucky, right away! I wasn’t until two weeks ago, when I discovered the following way of working.

Step 1 – Install the Isolated Storage Explorer

First be prepared and install the Visual Studio 2012 add in called: Isolated Storage Explorer. This will enable easy access to the Isolated Storage of your Emulator or actual Device for the app your developing. After installation you can find the Isolated Storage Explorer in the View menu.

Step 2 – Run your app and setup data

Now run your app, either on the Emulator or on your physical device. Make sure to setup all data. In my case I did search for some podcasts and subscribed to them. I also waited to make sure the podcast files were all downloaded completely. Make sure to shut down your app, and stop debugging.

Step 3 – Backup your isolated storage

To backup your isolated storage open the Isolated Storage Explorer, if you don’t have it visible you can find it in the View menu of Visual Studio. Then pick the button with the arrow pointing downwards to Take a Snapshot of the Isolated Storage and pick a folder where you want to save the Snapshot.

image

Restore your Isolated Storage

So now you’re prepared, if you restart your emulator or for some reason the app can’t be just updated on your phone and get’s a fresh install. Do the following.

Run your app and shut it down, to make sure that no Isolated Storage Files are locked.

Again make sure you have the Isolated Storage Explorer open and pick the button with the arrow pointing upwards to Restore a Snapshot and pick the folder you’ve used before to save the Snapshot.

When you now start your app, you will see that the Isolated Storage is restored. Hope you enjoy creating apps even more.

image