Floating FB popout byF5debug

Learn Windows Phone 7 Development in 31 Days – Day 16 – Working with Launchers in WP7

 

Introduction:

In this article we are going to see what Launchers are and what are the uses of Launcher in developing a Windows Phone 7 Application.

Launcher in Windows Phone 7 is an API used to launch some of the built in applications using which the user can select some task. Once the user selects the application, we can handle the task as per the convenient option to do some manipulations as per the task raised. Some of the example of using the launchers is triggering a contact application to select some contact information.    [more]

Launchers have some general steps to launch a particular application and steps are as follows

  • Creating an instance of the task
  • Setting the parameters to organize the task
  • Calling the show method to invoke the task

Let us see the list of Launchers available and the usage of each and every launcher tasks to get some clear idea on when to use each task to get a better performance.

Launchers Tasks:

  • SMS Compose Task – This task is used to send a message from the application. We can launch the SMS Composer of the Messaging application and we can optionally specify the recipients, body etc to make it easy. The message composer screen will be opened along with the default items and the message will not be sent unless and until the Send button is clicked.
  • Email Compose Task – This task is used to send Email message from the application which we develop. This task will launch the Email Composing screen with the options to load the data which we can be specified as static or dynamic using our code. The Email will not be sent unless and until the user presses the Send button from the task.
  • Phone Call Task – This task is used to make phone calls for the users within the application, we can specify properties like calling number, name etc but unless and until the call button is pressed manually the call will not be processed.
  • Web Browser Task – Used to launch the web browser to open a specified URL mentioned using the properties at run time.
  • Media Player Launcher Task– This task is used to launch the Media Player and play some media files of our choice by selecting the media file or by playing them randomly. Also we have options to make use of some of the properties like rewind, pause, forward etc to make it much easier to perform.
  • Connection Settings Task – This task is used to adjust the network settings connection by providing options for the users to handle it based on necessary settings.
  • Bing Maps Directions Task – This task is used to launch the BING maps to get the direction of a specified location by providing the location details as a parameter.
  • Bing Maps Task – This task is used to launch the BING maps application and search the location within the map. We can use the inbuilt options within the task to ZOOM in and ZOOM out to get the clear location.
  • Search Task – This task is used to perform some online search of the content which can be used to search for the application which we develop. This task performs a general search for the content which we specify, normally like the BING.
  • Share Link Task – This task is used to share some links to the social networking sites, we can use this task to launch from our application and share some links to the network.
  • Share Status Task – This task is used to share our status message to the social networking sites, we can use this task to launch from our application and send status messages to different social networking sites.
  • Marketplace Detail Task – This task is used to launch the Market place client application and displays the detailed information of a specific application which we want to look at, if no application parameter is passed, it opens by default, the current application from which it was called.
  • Market place Hub Task – This task is used to launch the Market place hub within the Marketplace client application to display the type of content which we are looking for.
  • Marketplace Review Task – This task is used to launch the Marketplace application and show the reviews page for the application from which the task will be invoked.
  • Marketplace Search Task – This task is used to search the market place with some particular content of application. Using this task launches the market place application with the specified search filter options to select from the list of applications.

Let us take an example on how to use one of the task and we will see in depth in our upcoming articles one by one. Now let us create a Phone Call task and see how to launch the Phone application to make a call.

Steps:

Open Visual Studio 2010 and create a new Silverlight for Windows Phone 7 Application with a valid project name as shown in the screen below.

clip_image002

Now let us add a button to invoke the PhoneCall Task and call a particular number, write the below code on the click event of the button as shown in the screen below. Also note that we need to add the below Using Directive in order to use the PhoneCall task (using Microsoft.Phone.Tasks; )

XAML Code:

01

<Grid x:Name="LayoutRoot" Background="Transparent">

02

<Grid.RowDefinitions>

03

<RowDefinition Height="Auto"/>

04

<RowDefinition Height="*"/>

05

</Grid.RowDefinitions>

06

 

07

<!--<span class="hiddenSpellError" pre="">TitlePanel</span> contains the name of the application and page title-->

08

<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">

09

<TextBlock x:Name="ApplicationTitle" Text="F5DEBUG WP7 TUTORIALS" Style="{StaticResource PhoneTextNormalStyle}"/>

10

<TextBlock x:Name="PageTitle" Text="Launchers" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>

11

</StackPanel>

12

 

13

<!--<span class="hiddenSpellError" pre="">ContentPanel</span> - place additional content here-->

14

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

15

<Button Content="Call Karthik!!!" Height="182" HorizontalAlignment="Left" Margin="80,89,0,0" Name="button1" VerticalAlignment="Top" Width="292" Click="button1_Click" />

16

</Grid>

17

</Grid>

Code Behind:

1

private void button1_Click(object sender, RoutedEventArgs e)

2

{

3

PhoneCallTask pctask = new PhoneCallTask();

4

pctask.DisplayName = "Karthikeyan";

5

pctask.PhoneNumber = "+9196000000096";

6

pctask.Show();

7

}

clip_image004

Now we are done with the code, build and execute the project by pressing F5 and we can see the application opened in Windows Phone 7 Emulator as shown in the screens below.

clip_image006

Conclusion:

So in this article we have seen what Launchers are in Windows Phone 7 development and the list of Launchers available. Also we have seen a sample on What PhoneCallTask is and how to use it practically with the Windows Phone 7 application development.

About Author: Karthikeyan Anbarasan, Microsoft MVP (Most Valuable Professional) in ASP.NET/IIS Architecture. He is the Founder and Chief Editor of the www.f5debug.net website and has authored books on Windows Phone and Business Intelligence(SSIS). He is also a Passionate Speaker and a Blogger on Microsoft Technologies.

You can Join Me On: Facebook, Twitter, Google Plus, LinkedIn

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Recent Posts

Random Posts

Most Viewed

URL Shortner

Create your own short urls!!!

Site Counter

free counters

Disclaimer

This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet. I have documented my personal experience on this blog.

Protected by Copyscape Web Plagiarism Finder

Site Meter