Understanding Launcher and Choosers in Windows Phone 7

One of the curious decision made by the WP7 team was the decision to lock every application into its own sandbox and not permit unauthorized access to various information stores, such as the contact list.  To get at this necessary information or to use it to help the user send a text or call someone WP7 provides Launchers and Choosers.

While both Launchers and Choosers share many similarities, they are inherently different in their purpose as well as their effect on your application.  Launchers are “fire and forget” actions that take you out of your application and into a new application, such as the web browser.  The most important aspect of Launchers is understanding that when they are launched they will cause your application to be “tombstoned”.  Choosers, on the other hand, are designed to be encapsulated bits of functionality that work within your application to accomplish the task, picking a picture for example.

In terms of usage, there is very little difference, from a progamatic sense, between setting up a launcher and chooser.  I have some code below that shows how one might invoke the WebBrowser task:

image 

Both Launchers and Choosers are very similar to Dialogs from client programming land.  For this code, I am hard coding http://www.google.com as the Url that shows up in the resulting Web Browser.  Remember that using this sort of task will cause the user to “leave” your application and thus causing your application to be “tombstoned”.  The user can still reach your application either by hitting the “Start” key on the device and then reselecting your application from the app list, or with enough presses of the “Back” button on the device.

Choosers are, as their name suggests, for choosing something; however they are still identified as a task.  Here is some code for selecting a contacts phone number from the users contact list:

image

The first thing to notice is that I am displaying two functions, both the event handler for the button this is tied to as well as an event handler for the choosers “Completed” event.  With the chooser you will still be leaving your application, but your application will not, in most cases, be “tombstoned”.

As of the current RTM release 16 total launchers and choosers and, for now, no way to create custom launchers and choosers, something I hope that will change in the future.  Below is a list of these launchers and choosers:

Launchers

  • EmailComposeTask
  • MarketplaceDetailTask
  • MarketplaceHubTask
  • MarketplaceReviewTask
  • MarketplaceSearchTask
  • MediaPlayerLauncher
  • PhoneCallTask
  • SaveEmailAddressTask
  • SavePhoneNumberTask
  • SearchTask
  • SmsComposeTask
  • WebBrowserTask

Choosers

  • EmailAddressChooserTask
  • CaptureCameraTask
  • PhoneNumberChooserTask
  • PhotoChooserTask

Launchers and Choosers appear to be Microsoft’s way to prevent people from harvesting information, secretly, from their mobile applications.  I do wonder how people will receive this, because as a developer I am worried about asking the user to select many of their contacts for an operation; they would have to go back and forth, rather then say selecting which contacts as a mass select.

Have fun using Launchers and Choosers.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s