Windows Phone 8 SDK offers a set of predefined tasks that enable applications to access phone functionality (Calendar, Map, SMS, Camera and more) and perform common tasks such as saving appointments, downloading map data for offline usage, sharing a media file on social networks and more. All this is performed via different Launchers and Choosers, each exposing a different API. The difference between a Launcher and a Chooser is that choosers return data, while launchers just start an application from the phone but do not return anything.
NOTE: It is important to consider that when you start a task, a separate application is launched to complete the task and your application is tombstoned.
NOTE: All Tasks that are available in Windows Phone 8 can be found in the Microsoft.Phone.Tasksnamespace. Do not forget to include this namespace when using any of the Task classes.
- SaveAppointmentTask – prompts the user to create a new appointment
- MapsTask – launches the built-in map app
- MapsDirectionsTask – launches the built-in map app with directions
- MapDownloaderTask – launches the map down-loader for the built-in map app
- ShareMediaTask – prompts the user to share a media file
The SaveAppointmentTask launches the built-in calendar application and prompts the user to add a new appointment to their calendar. The task API allows you to populate many of the fields of the new appointment.
private void btnLaunchAppointmentTask_Click(object sender, RoutedEventArgs e)
SaveAppointmentTask saveAppointmentTask = new SaveAppointmentTask();
DateTime currentTime = DateTime.Now;
saveAppointmentTask.StartTime = currentTime.AddHours(1);
saveAppointmentTask.EndTime = currentTime.AddHours(3);
saveAppointmentTask.Subject = "Meet John";
// appointment subject
saveAppointmentTask.Location = "Office";
// appointment location
saveAppointmentTask.Details = "Meet John to discuss product launch";
// appointment details
saveAppointmentTask.IsAllDayEvent = false;
saveAppointmentTask.Reminder = Reminder.FifteenMinutes;
saveAppointmentTask.AppointmentStatus = Microsoft.Phone.UserData.AppointmentStatus.Busy;
The MapDownloaderTask launches the built-in Map application settings and enables the user to download map data for offline use.
private void btnLaunchMapDownloaderTask_Click(object sender, RoutedEventArgs e)
MapDownloaderTask mapDownloa-derTask = new
The MapsTask launches the built-in Map application centered at the user`s current location. You can set a new location, a search term or map zoom level using the Center, SearchTerm and ZoomLevel properties as shown in the code snippet.
private void btnLaunchMapsTask_Click(object
sender, RoutedEventArgs e)
MapsTask mapsTask = new Maps-Task();
mapsTask.Center = new GeoCoordinate(51.5171, -0.1362); // London
// 1 - zoomed out, 20 - zoomedin
mapsTask.ZoomLevel = 7;
mapsTask.SearchTerm = "pizza";
The MapsDirectionsTask launches the built-in Map application with driving directions for getting from a starting location to a destination location. The starting and destination locations can be set as coordinates using the Start and End properties.
private void btnLaunchMapsDirectionsTask_Click(object sender, RoutedEventArgs e)
MapsDirectionsTask mapsDirectionsTask = new
mapsDirectionsTask.Start = new
LabeledMapLocation("London Victoria", new GeoCoordinate(51.495322, -0.144732));
mapsDirectionsTask.End = new
LabeledMapLocation("London Heathrow", new
The ShareMediaTask launches a dialog that enables a user to share a media file. The following code snippet demonstrates how to ask the user to pick a photo and then share it.
private void btnLaunchShareMediaTask_Click(object sender, RoutedEventArgs e)
PhotoChooserTask photoChooserTask = new PhotoChooserTask();
photoChooserTask.ShowCamera = true;
void photoChooserTask_Completed(object sender, PhotoResult e)
ShareMediaTask shareMediaTask = new
In this post we discussed what the new tasks in Windows Phone 8 are and how to use them. We showed how to prompt the user to add a new appointment, how to display a location or directions on a map and finally, how to share a media file.