WP7 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. Unlike Choosers, Launchers do not return a value back to the calling application.

Using Launchers in Your Application.


The Launcher APIs are belong to the Microsoft.Phone.Tasks namespace. You need to add a using directive for this namespace to the PhoneApplicationPage class file. All of the Launcher APIs function in a similar manner. First, you create an instance of the Launcher class you wish to use. Next, you set properties of the Launcher object that will determine the behavior of the task application when it is invoked. For example, you can specify a phone number that will be displayed when the Phone application launches. Finally, you call the Launcher’s Show method to launch the task application.It is important to note that when you use a Launcher, a separate application is launched to complete the task. For example, the EmailComposeTask invokes the Messaging application. When the separate application is launched, your application is deactivated and is no longer running. After completing the task, the user can return to your application, at which point it is reactivated.

Classes


Public class
CameraCaptureTask
Allows an application to launch the Camera application. Use this to allow users to take a photo from your application.Public class
ChooserBase<TTaskEventArgs>
The base class from which all choosers are derived. This class exposes a common function for showing the choosers and an event for handling the chooser result.Public class
EmailAddressChooserTask
Allows an application to launch the Contacts application. Use this to obtain the email address of a contact selected by the user.Public class
EmailComposeTask
Allows an application to launch the email application with a new message displayed. Use this to allow users to send email from your application.Public class
EmailResult
Represents an email address returned from a call to the Show method of a EmailAddressChooserTask object.Public class
MarketplaceDetailTask
Allows an application to launch the Windows Phone Marketplace client application and display the details page for the specified product.Public class
MarketplaceHubTask
Allows an application to launch the Windows Phone Marketplace client application.Public class
MarketplaceLauncher
This Windows Phone Marketplace Launcher API is deprecated. It will not be supported in future releases. Please use the new Windows Phone Marketplace APIs, MarketplaceDetailTask, MarketplaceHubTask, MarketplaceReviewTask, and MarketplaceSearchTask.Public class
MarketplaceReviewTask
Allows an application to launch the Windows Phone Marketplace client application and display the review page for the specified product.Public class
MarketplaceSearchTask
Allows an application to launch the Windows Phone Marketplace client application and display the search results from the specified search terms.Public class
MediaPlayerLauncher
Allows an application to launch the media player.Public class
PhoneCallTask
Allows an application to launch the Phone application. Use this to allow users to make a phone call from your application.Public class
PhoneNumberChooserTask
Allows an application to launch the Contacts application. Use this to obtain the phone number of a contact selected by the user.Public class
PhoneNumberResult
Represents a phone number returned from a call to the Show method of a PhoneNumberChooserTask object.Public class
PhotoChooserTask
Allows an application to launch the Photo Chooser application. Use this to allow users to select a photo.Public class
PhotoResult
Represents a photo returned from a call to the Show method of a PhotoChooserTask object or a CameraCaptureTask object.Public class
SaveEmailAddressTask
Allows an application to launch the contacts application. Use this to allow users to save an email address from your application to a new or existing contact.Public class
SavePhoneNumberTask
Allows an application to launch the contacts application. Use this to allow users to save a phone number from your application to a new or existing contact.Public class
SearchTask
Allows an application to launch the Web Search application.Public class
SmsComposeTask
Launches the Messaging application with a new SMS message displayed.Public class
TaskEventArgs
The EventArgs used by the Completed event for all Choosers.Public class
WebBrowserTask
Allows an application to launch the Web browser application.


Public class

 

EmailComposeTask

EmailComposeTask launches the Email application which displays a new email message. You can optionally specify recipients, a message subject, and a message body that are prepopulated in the new message. The message is not sent until it is initiated by the user.

EmailComposeTask emailComposeTask = new EmailComposeTask();
emailComposeTask.To = "user@example.com";
emailComposeTask.Body = "Email message body";
emailComposeTask.Cc = "user2@example.com";
emailComposeTask.Subject = "Email subject";
emailComposeTask.Show();

MarketplaceDetailTask

MarketplaceDetailTask launches the Windows Phone Marketplace client application which then shows the details page for a product specified by the unique identifier you provide.

MarketplaceDetailTask marketplaceDetailTask = new MarketplaceDetailTask();
marketplaceDetailTask.ContentIdentifier = "<ID>";
marketplaceDetailTask.Show();

MarketplaceHubTask

MarketplaceHubTask launches the Windows Phone Marketplace client application. Set the ContentType property to a value from the MarketplaceContentType enumeration to launch the hub to a particular type of content.

MarketplaceHubTask marketplaceHubTask = new MarketplaceHubTask();
marketplaceHubTask.ContentType = MarketplaceContentType.Music;
marketplaceHubTask.Show();

MarketplaceReviewTask

MarketplaceDetailTask launches the Windows Phone Marketplace client application which then displays the review page for your application.

MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();
marketplaceReviewTask.Show();

MarketplaceSearchTask

MarketplaceSearchTask launches the Windows Phone Marketplace client application which then shows the search results based on search terms you provide.

MarketplaceSearchTask marketplaceSearchTask = new MarketplaceSearchTask();
marketplaceSearchTask.SearchTerms = "accelerometer xna";
marketplaceSearchTask.Show();

MediaPlayerLauncher

MediaPlayerLauncher launches the Media Player application and plays the media file you specify. Media files are stored in isolated storage when saved to disk by the application and are stored in the application’s installation directory if they are bundled into the applications .xap file. You must specify one of these locations using the MediaLocationType enumeration. You can optionally specify that one or more controls should be shown by the Media Player using bitwise OR combinations of the MediaPlaybackControls values.

MediaPlayerLauncher mediaPlayerLauncher = new MediaPlayerLauncher();
mediaPlayerLauncher.Media = new Uri("MyVideo.wmv", UriKind.Relative);
mediaPlayerLauncher.Location = MediaLocationType.Data;
mediaPlayerLauncher.Controls = MediaPlaybackControls.Pause | MediaPlaybackControls.Stop;
mediaPlayerLauncher.Show();

PhoneCallTask

PhoneCallTask launches the Phone application and displays the specified phone number and display name. The phone call is not placed until it is initiated by the user.

PhoneCallTask phoneCallTask = new PhoneCallTask();
phoneCallTask.PhoneNumber = "55555555555";
phoneCallTask.DisplayName = "Gage";
phoneCallTask.Show();

SearchTask

SearchTask launches the Search application and performs search query you provide.

SearchTask searchTask = new SearchTask();
searchTask.SearchQuery = "NukeYourOffice";
searchTask.Show();

SMSComposeTask

SmsComposeTask launches the Messaging application which displays a new SMS message. You can optionally specify recipients and a message body that are prepopulated in the new message. The message is not sent until it is initiated by the user.

SmsComposeTask smsComposeTask = new SmsComposeTask();
smsComposeTask.To = "5555555555";
smsComposeTask.Body = "Check out this new app.";
WebBrowserTask

WebBrowserTask launches the Web browser and displays the URL you provide.

WebBrowserTask webBrowserTask = new WebBrowserTask();
webBrowserTask.URL = http://webservicesuk.com;
This entry was posted in WP7Dev.

One thought on “WP7 Launchers

Leave a Reply

Your email address will not be published.