This post is Day #7 in a series called the 31 Days of Windows Phone.
Yesterday I discussed how to leverage the Application Bar in your Windows Phone application. Today, we’re going to look at another core piece of functionality for your apps, the Launcher.
What are Launchers?
I often find myself describing Launchers as a “fire-and-forget” mechanism. You can use them to send email, view a map, take a picture, and more. We’ll cover each of the Launchers available to you as a developer on this platform. At the end of this post, there is a downloadable project that includes code samples for each of the Launchers described here.
One thing to remember about some of these Launchers is that in the emulator, some of them just plain don’t work. 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. This is where you should attend my “office hours.” Each Thursday, in Columbus, OH, I make myself available from 7-9am for application testing on real devices. Hit me up if you’d like to try yours out.
For each of these Launchers, you will also need to make sure that you have this statement at the top of your code-behind file. We need a reference to Microsoft.Phone.Tasks.
using Microsoft.Phone.Tasks;
For a quick look at the list of Launchers, here’s what you’ve got so far:
- BingMapsDirectionsTask – allows you to provide turn by turn directions from either a start AND end point, or from the user’s current location to an end point.
- BingMapsTask – you can use this task to launch a map with a specific point labeled.
- ConnectionSettingsTask – a task that allows you to direct your users to their wi-fi, bluetooth, and other settings of their device.
- EmailComposeTask – allows the user to send an email using their email accounts.
- MarketplaceDetailTask – launches the Windows Phone Marketplace, and takes the user to a specific product offering.
- MarketplaceHubTask – launched the Windows Phone Marketplace, and allows you to specify a category of applications to show by default.
- MarketplaceReviewTask – takes the user to the Windows Phone Marketplace to review the current application.
- MarketplaceSearchTask – launches search results for the Windows Phone Marketplace, based on a search term your user enters (or that you specify.)
- MediaPlayerLauncher – launches the internal Media Player application, and plays the media file that you specify.
- PhoneCallTask – launches the Phone application and displays the provided phone number and name. The phone call isn’t dialed until the user presses “Call.”
- SearchTask – think of this as a way to provide a Bing search from your application.
- SMSComposeTask – launches the Messaging application, and presents the user with the ability to send a text message. You can specify recipients and message body, but the user has to send it.
- WebBrowserTask – launches the Web Browser, and navigates to the specified URL.
Launching a Launcher
Each of the Launchers certainly have their own set of properties, but after setting any of them up, you need to .Show() them to the user. To do this, you simply call the Show() method on your Launcher.
As an example, here’s the SMSComposeTask:
SmsComposeTask sct = new SmsComposeTask(); sct.To = "5555555555"; sct.Body = "Call me when you have a chance. Let's do lunch today."; sct.Show();
I linked each of the Launcher names above to their MSDN articles, where you can see the properties of each. It didn’t make much sense for me to replicate the great work they’re doing over there.
Tomorrow, we’re going to talk about Choosers. The cousins of Launchers, they allow you to get data from your user’s phone (with their permission, of course.) See you then!
Download the Code
I have included a simple project that uses each of the above Launchers in an example.
Leave a Reply