Launchers and Choosers for Windows Phone
This article demonstrates how to use Launchers and Choosers in Windows Phone
Windows phone uses launchers and choosers to provide access to common device functionality and services. When a particular function is required, a launcher/chooser is called to start the built in app and perform the required task; on completion control returns to the calling app.
The main difference between launchers and choosers is that a chooser usually returns data back to the app (for example taking a photo) while a launcher does not (for example, sending an email).
The code example app described here uses a launcher to start the Media Player and play a video, and uses the Chooser to launch the Camera and take a photo. Each of the Launchers and Choosers have their own set of properties. After setting any of those properties, we need to call Show() method. For Choosers we need to implement the event handler for when the user has taken a picture, in order to get the image back to handle.
First create a project with Windows Phone Application Template. Once the project is created, add the reference Microsoft.Phone.Tasks (needed for both choosers and launchers).
Launch Media Player
To launch the Media Player using the Launcher API, first create the instance of the MediaPlayerLauncher then set the media file to be launched and then call the Show() function to launch the media player.
This code launches the default media player of the device and start playing the file.
Launch Camera chooser
When user completes the task, an event is raised and the event handler cameraCaptureTask_Completed() receives a photo in the result, which is then displayed in the screen.
void cameraCaptureTask_Completed(object sender, PhotoResult e)
if (e.TaskResult == TaskResult.OK)
BitmapImage bmp = new BitmapImage();
image1.Source = bmp;
The full source code of the example is available here: File:LauncherAndChooser.zip