Share via


Choosers

Version: 1.0.0

Description

The choosers and launchers APIs allow an application to integrate with common operating system tasks such as taking a picture, finding an address or a contact, making a call, or saving a ring tone. This hands-on lab walks you through the choosers available on Windows Phone.

Overview

The launchers and choosers framework enables Windows Phone applications to provide common functions such as placing phone calls, sending emails, and taking pictures for their users.

The Windows Phone application model isolates every application in its own work area for both execution (including memory isolation) and file storage. Windows Phone applications are not able to directly access common information stores such as the contacts list or to directly invoke other applications such as phoning or messaging. To support scenarios requiring common tasks such as phoning or messaging, the Windows Phone provides a set of launcher and chooser APIs that enables applications to access these useful phone features indirectly. The launcher and chooser APIs invoke distinct built-in applications that replace the currently running application. The launchers and choosers framework provides the end user with a seamless experience while masking the application switching that occurs in the background.

The framework components are as follows:

  • Chooser - An “open file dialog” action, where information is selected from a specific phone application’s storage area, for example, selecting an email address, contact, or picture

Below is the complete list of choosers that Windows Phone 7 Codenamed “Mango” supports:

Choosers

  • EmailAddressChooserTask - Enables an application to launch the Contacts application, so users can extract selected contact email addresses
  • CameraCaptureTask - Enables an application to launch the Camera application, so users can take a photo from within an application
  • PhoneNumberChooserTask - Enables an application to launch the Contacts application, so users can extract selected contact phone numbers
  • PhotoChooserTask - Enables an application to launch the Photo Chooser application, so users can select a photo
  • Contacts – Allows an application to search for contacts according to their name, e-mail address or phone number.
  • Appointments – Allows an application to search for appointments which occur in a specified time span.

While it is always a good practice to think about application tombstoning during Window Phone development, one should consider tombstoning even more seriously when dealing with launchers and choosers.

When does an application get tombstoned?

Generally speaking, an application gets tombstoned [that is, it is placed in the back stack] when a user forward navigates away from it. While there are a few exceptions to this general rule, applications in the background may be tombstoned at any time if the system requires additional resources to carry out the current foreground activity.

An application will not be automatically tombstoned when it launches an experience that feels to the user like an extension of the original application. These experiences are native flows that help the user complete some task, like choosing a photo. Avoiding tombstoning in these cases ensures a smooth flow between the application and the experience it has called [for example, no delay between choosing a photo and returning to the application that uses it].

Below is the list of native experiences that, when invoked, do not trigger an automatic tombstone in the calling application:

  • PhotoChooserTask
  • CameraCaptureTask
  • MediaPlayerLauncher
  • EmailAddressChooserTask
  • PhoneNumberChooserTask

There are three scenarios in which an application in the background will immediately be tombstoned:

  • User forward navigates away from an application [for example, user presses the Start key]
  • Application invokes choosers not listed above
  • System requires more resources to carry out a foreground activity
Note:
 All the above information regarding tombstoning is true for Windows® Phone 7.0. On Windows® Phone 7.1 launchers and choosers never initiate tombstoning, but it may be initiated nonetheless if the device requires additional resources. For more information on the new 7.1 application execution model please refer to documentation.

Objectives

Upon completion of this lab, you will:

  • Be familiar with the choosers concept as implemented in the Windows Phone 7 application model
  • Understand how and when to use choosers
  • Have created a Silverlight application that uses the wide array of available choosers

Prerequisites

The following is required to complete this hands-on lab:

  • Microsoft Visual Studio 2010 Express for Windows Phone or Microsoft Visual Studio 2010
  • Windows Phone Codenamed “Mango” Developer Tools
    Note:
    Note: You can download all of these tools together in a single package from https://go.microsoft.com/?linkid=9772716.

Exercises

This hands-on lab is comprised of the following exercises:

  • Introduction to the Windows Phone Choosers

Estimated time to complete this lab: 30 minutes.