MOBILE

Introducing Windows Phone 7 Launchers and Choosers

2/15/2011 11:46:06 AM
When a third-party application runs on a Windows Phone, it runs in an execution environment that is highly restricted. The Windows Phone OS must be restrictive in order to protect unsuspecting users of mobile devices from potential malicious application behavior, which may include stealing personal data stored on the phone, dialing phone numbers without users' knowledge, or corrupting other applications' data stores. One of the major restrictions that Windows Phone OS places on mobile applications is limiting them to their own execution environment, or sandbox, and not allowing them access to other applications' space or internals of the operating system.

Yet many applications need to access the system features of the phone, to play a music file in the media library, for example, or to take a photo, or to send a text message or an e-mail. Windows Phone 7 OS enables such application interactions with the device via a set of Application Programming Interface (API) tasks referred to as launchers and choosers. It is relatively easy to use launchers and choosers from within your application, but when one is invoked or when a user presses hardware buttons on the phone, managing application state does get a little tricky.

Introducing Windows Phone 7 Launchers and Choosers

When an application executes, the Windows Phone 7 OS confines it to its own space, or sandbox. Both memory and file storage are isolated within that sandbox—one application cannot access or alter another's memory or file storage. Neither can one application directly call another or access a shared data store—such as a list of contacts, for example. There are obvious reasons for this behavior; Microsoft must ensure that the Windows Phone 7 platform is as secure and stable as possible, and isolating applications is one giant step toward getting there.

There is a set of built-in APIs that provide access to the most common features of Windows Phone 7. These APIs help us perform tasks, such as saving a contact's e-mail address or phone number, or placing a phone call (with the mandatory prior user authorization, of course), that require access to shared resources on the phone.

Launchers and choosers, which can be thought of as system functions provided by the Windows Phone OS, provide you with the means to call into these applications. The difference between a launcher and a chooser is small but important: choosers provide a return value into the calling application, whereas launchers do not. If you think about a task of composing an e-mail message, for example, then it is sufficient to "fire and forget" an e-mail application, allowing users to create and send an e-mail. A launcher is an ideal solution for this task. On the other hand, an application allowing us to select a photo from the photo library on the phone needs to pass the selected photo to our application. Windows Phone 7 provides a chooser to perform such a task.

An important concept to remember is that launchers and choosers are separate applications. Since one of the core design principles behind Windows Phone 7 is to maximize battery life, only one application is allowed to execute on the phone at any time. Therefore, if you invoke a launcher or chooser from within your application, that launcher or chooser will replace your application and become the running application. Depending on the circumstances, your application may enter one of several states when that happens. Tables 1 and 2 list the launchers and choosers available on the Windows Phone 7 platform today. You'll find all of them in the Microsoft.Phone.Tasks namespace; therefore, to use any of them, be sure to import that namespace into your application.

1. Launchers

Table 1 lists launchers offered on the Windows Phone 7 platform, together with a brief description of functionality offered by each one of those launchers.

Table 1. Windows Phone 7 Launchers and Their Functions
LauncherFunction
EmailComposeTaskLaunch the e-mail application with a new message displayed.
MarketplaceDetailTaskLaunch the Windows Phone Marketplace client application and display the details page for the specified product.
MarketplaceHubTaskLaunch the Windows Phone Marketplace client application.
MarketplaceReviewTaskLaunch the Windows Phone Marketplace client application and display the review page for the specified product.
MarketplaceSearchTaskLaunch the Windows Phone Marketplace client application and display the search results from the specified search terms.
MediaPlayerLauncherLaunch the media player.
PhoneCallTaskLaunch the Phone application; use this to allow users to make a phone call from your application.
SaveEmailAddressTaskLaunch the Contacts application; use this to allow users to save an e-mail address from your application to a new or existing contact.
SavePhoneNumberTaskLaunch the Contacts application; use this to allow users to save a phone number from your application to a new or existing contact.
SearchTaskLaunch the Web Search application.
SmsComposeTaskLaunch the SMS application.
WebBrowserTaskLaunch the Web Browser application.

2. Choosers

Table 2 lists and describes the choosers available on the Windows Phone 7 platform.

Table 10.2. Windows Phone Choosers and Their Functions
ChooserFunction
EmailAddressChooserTaskLaunch the Contacts application and obtain the e-mail address of a contact selected by the user.
CameraCaptureTaskLaunch the Camera application and allow users to take a photo from your application.
PhoneNumberChooserTaskLaunch the Contacts application and obtain the phone number of a contact selected by the user.
PhotoChooserTaskLaunch the Photo Chooser application and select a photo .


Other  
  •  Java Mobile Edition Security : Development and Security Testing (part 3) - Code Security & Application Packaging and Distribution
  •  Java Mobile Edition Security : Development and Security Testing (part 2) - Reverse Engineering and Debugging
  •  Java Mobile Edition Security : Development and Security Testing (part 1) - Configuring a Development Environment and Installing New Platforms & Emulator
  •  Java Mobile Edition Security : Configurations, Profiles, and JSRs
  •  Programming the Mobile Web : Performance Optimization
  •  Programming the Mobile Web : Testing and Debugging (part 3) - Client-Side Debugging
  •  Programming the Mobile Web : Testing and Debugging (part 2) - Server-Side Debugging & Markup Debugging
  •  Programming the Mobile Web : Testing and Debugging (part 1) - Remote Labs
  •  Windows Phone 7 : Working with Controls and Themes - Adding Transition Effects
  •  Windows Phone 7 : Working with Controls and Themes - Understanding Frame and Page Navigation
  •  Windows Phone 7 : Working with Controls and Themes - Panorama and Pivot Controls
  •  Programming the Mobile Web : Widgets and Offline Webapps - Platforms (part 5) - Windows Mobile & BlackBerry
  •  Programming the Mobile Web : Widgets and Offline Webapps - Platforms (part 4) - Windows Mobile & BlackBerry
  •  Programming the Mobile Web : Widgets and Offline Webapps - Platforms (part 3) - webOS & Android
  •  Programming the Mobile Web : Widgets and Offline Webapps - Platforms (part 2) - iPhone, iPod, and iPad
  •  Programming the Mobile Web : Widgets and Offline Webapps - Platforms (part 1) - Symbian/Nokia
  •  Programming the Mobile Web : Widgets and Offline Webapps - Standards
  •  Mobile Application Security : BlackBerry Security - Networking
  •  Mobile Application Security : BlackBerry Security - Local Data Storage
  •  Themes on Windows Phone 7 Devices (part 2) - Changing the Theme & Detecting the Currently Selected Theme
  •  
    Top 10
    ASP.NET 3.5 : The HTTP Request Context - The HttpRequest Object
    ASP.NET 3.5 : The HTTP Request Context - The HttpResponse Object
    Active Directory Domain Services 2008 : Enable a Group Policy Object Link, Enforce a Group Policy Object Link, Remove the Enforcement of a Group Policy Object Link
    Active Directory Domain Services 2008 : Link a Group Policy Object, Remove a Group Policy Object Link, Disable a Group Policy Object Link
    Writing 64-Bit Applications for Windows 7 (part 2)
    Writing 64-Bit Applications for Windows 7 (part 1) - OVERCOMING 64-BIT DEVELOPMENT ISSUES
    Developing a Windows 7 Strategy : DETERMINING THE USER WINDOWS 7 COMFORT LEVEL
    Windows Server 2008 and Windows Vista : Group Policy Processing Events (part 2) - Foreground Group Policy Processing
    Windows Server 2008 and Windows Vista : Group Policy Processing Events (part 1) - Background GPO Policy Processing
    Kyocera Mita FS-C5150DN
    Most View
    Sharepoint 2007: Add a Column to a List or Document Library
    Server 2008 : Hardening Server Security
    Java Mobile Edition Security : Development and Security Testing (part 2) - Reverse Engineering and Debugging
    Zotac Geforce GTX 670 AMP! Edition
    Huge Screen Supertest (Part 9) - Samsung 8 Series S27A850D
    Windows Server 2008 : DHCP/WINS/Domain Controllers - Securing DHCP
    How Much Is Your Data Worth? (Part 2)
    Samsung Galaxy SIII And HTC One X: A Detailed And Thorough Comparison
    Algorithms for Compiler Design: INTERMEDIATE CODE GENERATION
    SharePoint 2010 : Operations Management with the SharePoint Central Administration Tool (part 5) - Reviewing Security Settings in SPCA
    IIS 7.0 : Using Command Line Tools - Microsoft.Web.Administration
    Klipsch Image S4i Earphones
    Algorithms for Compiler Design: THE LR PARSER
    Working with Basic and Dynamic Disks
    Macbook Air vs. Ultrabook Platform (Part 1)
    Cooler Master CM Storm Sirus 5.1
    jQuery 1.3 : Table Manipulation - Sorting and paging (part 1) : Server-side sorting & JavaScript sorting
    iPhone 3D Programming : Holodeck Sample (part 1) - Application Skeleton
    The giant of Cambridgeshire (Part 4) - Processor and cores
    XNA Game Studio 4.0 : Windows Phone Sensors and Feedback (part 2) - Locating a Windows Phone with the Location Service