Launchers and Choosers: introduction
published on: 10/29/2010 | Views: N/A | Tags: Tasks
In this post I will make a brief introduction to the Windows Phone 7 "Launchers and Choosers" .
Launchers and Choosers are APIs that enable Windows Phone applications to provide a set of common tasks to their users (indirect access to the phone features), such as placing phone calls, sending email, and taking pictures.
Launchers
Launchers are a set of APIs that Windows Phone applications can use to enable common tasks such as making a phone call or sending an email but no data is returned to the calling application.
Let`s take for example utilization of the existing phone functionality which is a pretty common scenario for a phone app. That are features like sending sms, email searching the web etc. Note that when you develop your app you do not have to access to these features directly so you have to use Microsots API's - so called "Launchers and Choosers" to access them .
Each of the Launchers have their own set of properties, but after setting any of them up, you need to call the Show() method in order to show them to the user.
Example:
WebBrowserTask webBrowserTask = new WebBrowserTask(){URL = "http://www.windowsphonegeek.com"};
task.Show();
Here is a list of the currently available Launchers:
Namespace: Microsoft.Phone.Tasks
Assembly: Microsoft.Phone (in Microsoft.Phone.dll)
EmailComposeTask - allows you to send email from your application (launches the Email application which displays a new email message).
MarketplaceDetailTask - launches the Windows Phone Marketplace client application and display the details page for the specified product..
MarketplaceHubTask - launches the Windows Phone Marketplace client application.
MarketplaceReviewTask - allows an application to launch the Windows Phone Marketplace client application and display the review page for the specified product.
MarketplaceSearchTask - launches the Windows Phone Marketplace client application which then shows the search results based on search terms you provide.
MediaPlayerLauncher - launches the Media Player application and plays the specified media file.
PhoneCallTask - allows your application to launch the Phone application that allows users to make a phone call from your application.
SearchTask - launches the web Search application.
SmsComposeTask - launches the Messaging application which displays a new SMS message.
WebBrowserTask - launches the Web browser and displays the specified URL.
Note: Unfortunately some Launchers don't work in the emulator. For example, the EmailComposeTask assumes you have an email account set up on the device. Because the emulator prevents you from creating email accounts, you won't be able to test this.
Choosers
A Chooser is an API that launches one of the built-in applications through which a user completes a task, and which returns some kind of data to the calling application.
The difference between a launcher and a chooser is simply that choosers return data.
For example your app can use a Chooser to show the PhotoChooser application so that you will be able to select a photo from the existing ones or you can launch the CameraCaptureTask in order to take a photo.
Each of the Chooser shave their own set of properties, but after setting any of them up, you need to call the Show() method in order to show them to the user.
Unlike the launcher, you have to give your chooser a way to return data. This is done using the choosers Completed event.
Example:
PhotoChooserTask photoChooserTask = new PhotoChooserTask();
this.photoChooserTask.Completed += new EventHandler<PhotoResult>(photoChooserTask_Completed);
photoChooserTask.Show();
private void photoChooserTask_Completed(object sender, PhotoResult e)
{
BitmapImage image = new BitmapImage();
image.SetSource(e.ChosenPhoto);
this.img.Source = image;
}
Here is the list of the currently available Choosers:
Namespace: Microsoft.Phone.Tasks
Assembly: Microsoft.Phone (in Microsoft.Phone.dll)
CameraCaptureTask - launches the Camera application for the user to take a photo.
EmailAddressChooserTask - launches the Contacts application and allows the user to select a contact's email address.
PhoneNumberChooserTask - launches the Contacts application and allows the user to select a contact's phone number.
PhotoChooserTask - launches the Photo Chooser application for the user to choose a photo.
SaveEmailAddressTask - launches the contacts application and saves the provided email address to the Contacts list.
SavePhoneNumberTask - launches the contacts application and saves the provided phone number to the Contacts list.
That is all you need to know about Launchers and Choosers in order to begin developing your app. In the next few posts I am going to explain in more details how to use each of this tasks so that you can build a consistent and fully functional app.
You can also follow us on Twitter @winphonegeek
Comments
Our Top Articles & Free books
- Our FREE e-book: "Windows Phone Toolkit In Depth" 2nd edition
- 400+ Windows Phone Development articles in our Article Index
- 21 WP7 Toolkit in Depth articles covering all controls
- 12 WP7 Coding4Fun Toolkit in Depth articles covering all controls
- Performance Tips when creating WP7 apps
- Creating a WP7 Custom Control in 7 Steps
- WP7 working with VisualStates: How to make a ToggleSwitch from CheckBox
- What makes a WP7 App successful
- Creating theme friendly UI in WP7 using OpacityMask
- Implementing Windows Phone 7 DataTemplateSelector and CustomDataTemplateSelector
- All about Splash Screens in WP7 – Creating animated Splash Screen
- Getting Started with Unit Testing in Silverlight for WP7
- WP7 WatermarkedTextBox custom control
Our Top Tips & Samples
- All about WP7 Isolated Storage series
- WP7 Dynamically Generating DataTemplate in code
- 5 tips for a successful WP7 Marketplace submission
- WP7: Navigating to a page in different assembly
- WP7 ContextMenu: answers to popular questions
- WP7 ListBox: answers to popular questions
- WP7 working with Images: Content vs Resource build action
- WP7 Element Binding samples
- WP7 working with XML: reading, filtering and databinding
- Drawing in WP7: #2 Drawing shapes with finger
- WP7 TextBox Light theme problems - the solution
- Changing the WP7 Panorama Background Image dynamically with Animation
