Category Archives: Windows Phone

Tips and tricks when using voice recognition in a Windows Phone 8 app

While working (again) on 2Day, I encountered small issues with voice recognition. The next version of 2Day will bring support for both speech recognition (use your voice to set the title of a task) and voice commands (speak to your phone to perform operations, for example: “2Day add a reminder tomorrow at 9PM”).

While developing those new features I used two distinct API for voice recognition:

The first one provides no UI while the second one includes a default GUI which is uniform across apps and utilities:


Issue 1: stop music playback automatically

In 2Day, I use the SpeechRecognizerUI when the user must confirm a choice while seeing what is visible on the screen. When using those APIs I faced a first problem which is music playback is not stopped automatically during voice recognition. It turns out a simple API can be used for this:

public void PauseMusicPlayback()
    this.wasPlayingMusic = MediaPlayer.State == MediaState.Playing;
    if (this.wasPlayingMusic)

public void ResumeMusicPlayback()
    if (this.wasPlayingMusic)
        // it looks like FrameworkDispatcher.Update() is needed when using the MediaPlayer

With a simple boolean field, I can save before starting voice recognition if I will have to resume music playback.

Issue 2: use default sound with SpeechRecognizer

When using the SpeechRecognizer class (the one without the default UI) I faced another problems: start/end of voice recognition is not surrounded by the small system sound that indicates that the recognition has started/ended. I thought the easiest way to get this sound as a WAV file on my machine was to use an Audio Capturing tool such as Audacity.

Long story short: that was a bad idea. And it turns out… The original sound files are installed with the SDK !

If you browse the following directory C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.0\Sounds you will be able to get the 2 WAV files ! And use them in your app (you can see my older blog post about how to play WAV file in a Silverlight Windows Phone app).


Hope it helps 🙂

Welcome 2013 :-)

This is the perfect time to take a look at what happened in the last few months as well as what’s on the roadmap for next year. So let’s start by taking a look at 2012…



  • In November, I gave a presentation about Windows Phone 8 at SFEIR Plays

sfeir plays

Blog posts

The last year I blogged mostly about Windows Phone stuff. This is not a surprise as I’m busy (on my personal time…) working for my 2Day todo-list application. I’m finalizing a major release that should be submitted to the marketplace soon with a ton of new features and improvement (several blog posts should highlight some topics from a developer point of view).

Here is the full list of article (oldest first):

Next year

2013 should very busy too 🙂

  • In mid-February, I will speak again during the TechDays in Paris. The topic is the same as last year: performance optimization for Windows Phone applications. However, with Windows Phone 8 we’ve plenty of new topics to cover !
  • In late-February I will fly to Redmond for the MVP Summit 2013. It will be my sedond time there. As aways, all the content will be under NDA… I will share a room with my friend Jose Fajardo I met at //BUILD/ 2011 !
  • In March, I should setup an event with my company and Microsoft in Grenoble talking about Windows 8 and Windows Phone 8

I’m still deeply invested with 2Day so hopefully you should see more tips and tricks about Windows Phone. As a Windows 8 version is also on its way, that should give me many reasons to write new blog posts.

Happy new year dear readers !




Updating the live tiles when the exits: WP8 weirdness

While working on the next version of my todo-list Windows Phone app 2Day, I encountered a strange issue with live tiles management I’m sharing in this blog post…



You can manage tiles of a Windows Phone application in several ways. You can setup the tile with a remote image URI that will be fetched and updated by the system. This is useful for example when the same tile is pushed to many users (for example in a news reader app). You can also setup the tile with a local image. In that case, you can generate the image dynamically on the phone based on specific user’s information.

This is what the later option that is used in 2Day:

2Day tiles

The workflow to do that is the following:

  • the user exits the app
  • an image is generated using the WritableBitmap class
  • the image is saved in the local storage of the app
  • the tile is updated using the ShellTile API

Upgrading 2Day to Windows Phone 8

While upgrading 2Day to Windows Phone 8, I decided to leverage fast-resume. Fast-resume is a new capability that can be used by Windows Phone applications. It allows to reuse the latest instance of the app when the user presses the tile instead of creating a new instance each time. All you have to do is to set the ActivationPolicy attribute to Resume in the WMAppManifest.xml file:

The issue

The problem I had was that after my app was suspended, it wasn’t able to start over with fast-resume.

The app was stuck in a “Resuming…” dialog. After several hours tweaking the code, I found out the issue disappeared when I removed the code which updated the live tile… Strange isn’t it ? Tweaking more the code, I found out it was the use of the WritableBitmap that was the cause of this issue. I searched over the Internet for a couple of days, asked in new dedicated topics on MSDN forums but no one had a solution.

My workaround

I finally decided to move the code which updates the tiles from the Deactivated event of the Application to the OnNavigatedFrom method of the main page of my app.

And that did the trick ! It’s working like a charm now 🙂


If you have a Windows Phone app and you’re updating tiles locally on the phone… Make sure to update your tiles when you’re navigating away from the main page and not in the Deactivated event 🙂

I’m not sure what is causing the problem… but it looks like I’m not the only one facing it as I was contacted on Twitter about the problem.