Windows Phone – Launchers & Choosers

Launchers and Choosers have been around since the first version of Windows Phone and basically allow the developer to integrate into the operating system.  For example, there is a ‘Task’ to make a phone call or to compose an email.  I like to define Launchers & Choosers as follows

  1. Launchers – ‘Just Launch it and Forget it’ – Basically, you launch something out the the OS, possibly passing some parameters and hand control over to the operating system.  Don’t expect the user to always come to your application and at this point you will be tombstoned or go into dormant state.  For example, you launch a phone call, the user might hit the start button, and go to another application and never return to your app until it’s needed again
  2. Choosers – this lets you pull information from the operating system in a way that keeps the users data secure and private.  For example, you can ask the user to select a contact and it will return contact information.

With Windows Phone Mango tools out, there are some new Launchers and Choosers that can be of use to developers.  You will find all of them un der the Microsoft.Phone.Tasks namespace on MSDN.  I’ll just go through a summary of the new ones for Mango.

The Launcher Tasks

As developers we did not really get that many new launchers but the ones we got I think will be useful if you are creating mapping applications.


The class names are pretty self explanatory but essentially the three do the following

  1. BingMapsDirectionsTask – Will show directions for using the Maps application
  2. BingMapsTask – will start the Maps application at the defined center point and if a search term is passed in it will add pins on the map that match the search term.

There is also a LabeledMapLocation class that is used with the BingMapsDirectionsTask that is basically a latitude/longitude with a string label


And using these are straight forward.  To use the BingMapsDirectionsTask you can use the following code

BingMapsDirectionsTask task = new BingMapsDirectionsTask()
    Start = new LabeledMapLocation("Current Position", new System.Device.Location.GeoCoordinate(43.65365522976227, -79.39292348921275)),
    End = new LabeledMapLocation("CN Tower", new System.Device.Location.GeoCoordinate(43.642600285590795, -79.38728012144566)),

which will result in the following in the Maps application using the emulator


BingMapsTask is just as easy

BingMapsTask task = new BingMapsTask()
     Center = new System.Device.Location.GeoCoordinate( 43, -79),
     SearchTerm = "CN Tower",
     ZoomLevel = 15

And results in



The Chooser Tasks

In Windows Phone Mango, we have four new chooser tasks.  Remember, choosers will return something back to us via a Completed event.

  1. AddressChooserTask – allows you to get the address of a contact chosen by the user
  2. SaveContactTask – allows you to initiate a save contact for the user to complete
  3. GameInviteTask – allows you to show the game invite screen to allow user to invite someone else to a multiplayer game session
  4. SaveRingtoneTask – allows you to initiate a save ring tone for the user to complete

I’ll do a quick example on saving a contact.  Essentially you have to create a new SaveContactTask, fill in some properties and call the show event.  The possible properties are


and the sample code to save is as follows

SaveContactTask task = new SaveContactTask()
    Company = "RedBit",
    FirstName = "Mark",
    HomeAddressCity = "Toronto",
    HomeAddressCountry = "Canada",
    HomeAddressState = "Ontario",
    HomeAddressStreet = "123 Any Street",
    HomeAddressZipCode = "75038",
    HomePhone = "416-123-4567",
    JobTitle = "Not Sure :)",
    LastName = "Arteaga",
task.Completed += new EventHandler<SaveContactResult>(task_Completed);

and our completed event handler is as follows

void task_Completed(object sender, SaveContactResult e)
    if (e.TaskResult != TaskResult.OK)
        MessageBox.Show("Is there a reason you didn’t save!");

which results in


and when the user is done, because we wired up the Completed event we will get the appropriate message if the user saved the contact or not.

The Share Tasks

You are probably wondering what the heck is a ‘Share Task’.  Well this is essentially a Launcher but it’s new to Mango and allows you to share the user’s status (ie Facebook status updates) or share a link.

  1. ShareStatusTask – allows user to share a status message on social network of choice
  2. ShareLinkTask – essentially same as status but will share a link on social network of choice

and the object model looks like this


Unfortunately this doesn’t work in the emulator but basically what happens on a device is a “Post Message” page pops up, user can select which social network they want to post to and click send.  They do have to option of modifying the post.

So there you have it, some of the new Launchers & Choosers available in Mango.  I think they are useful and already have plans to integrate into some of our apps and customer apps.


Warning: count(): Parameter must be an array or an object that implements Countable in /nfs/c07/h02/mnt/110221/domains/ on line 405

Leave a Reply