Sudhindra Kovalam's Blog

My Geeky Blog

Windows Phone 7 : Launchers and Choosers

with 5 comments

Windows Phone 7 seems to have captured my attention a lot these days. So I am ( and will be ) blogging about Windows Phone 7 like crazy. I believe that it is Microsoft’s first step in the right direction (in the phone OS business). So coming back to Windows phone 7 Platform. We all, by now know that all applications in Windows Phone 7 runs in its own sandbox (execution and file storage, both). And since, we  are developing apps for windows Phone 7, we will certainly need access to common, phone related functionality, say like sending an email, SMS etc. Recently, in Community Tech Days Pune, in the Windows Phone 7 app development session by Mayur Tendulkar, a very cool app was demoed for Windows Mobile 6.x. This app would send “happy new year” or “happy holidays” message to all the contacts in your phone. The idea was pretty cool. So for designing this app, we would need access to the phone’s contact list and then, will have to use the phone’s SMS API to send out Text messages. It is a different ball game here on Windows Phone 7 platform. Windows Phone 7 doesn’t give you access to native functionality directly, so Microsoft has exposed certain common functionality that you would want to use in your apps in the form of Launchers and Choosers.

A Launcher is an API, that launches built in functionality for the user to accomplish some task and returns nothing back to the calling function in  your app. API to make calls, Send SMS or Emails etc are an example of such APIs

A Chooser on the other hand is an API , that launched a  built in functionality for the user to accomplish some task and returns back the data that was chosen by the user to the app. API for Choosing contacts, photos etc. come under this category.

Important Note : Your application de-activates (i.e. gets tombstoned), when you trigger a launcher or a chooser. (Not sure what tombstoned means, read more about Windows Phone app life cycle here ). How to use Launchers in your application : Launchers are available in Microsoft.Phone.Tasks Namespace. Make sure to add a using statement for this namespace.

As of now Following Launchers have been exposed to us (Not exactly …):

1. EmailComposeTask :

As the name suggests, The EmailComposeTask lets you compose emails and send ‘em. You will off course need to setup an email account before you can actually use the email compose functionality. The good news, if no email account has been setup, the shell will ask you to setup an account. ( I guess in the final RTW SDK, this might actually trigger email setup, if not done already)


EmailComposeTask emailComposeTask = new EmailComposeTask();
emailComposeTask.To = "bill.gates@microsoft.com";
emailComposeTask.Body = "Windows Phone Rocks!!!"
emailComposeTask.Cc = "SteveBallmer@MSFT.com";
emailComposeTask.Subject = "Windows Phone";
emailComposeTask.Show();

2. PhoneCallTask:

Again, quite evident by the name itself. Phone call task will let you make a phone call.

PhoneCallTask phoneCallTask = new PhoneCallTask();
phoneCallTask.PhoneNumber = "180018001800";
phoneCallTask.DisplayName = "Steve Jobs";
phoneCallTask.Show();

Quite a wrong person to call, I know ;)

3. SMSComposeTask :

Lets you compose an SMS

SmsComposeTask smsComposeTask = new SmsComposeTask();
smsComposeTask.To = "1800-180-1800";
smsComposeTask.Body = "Cool Phone!!";
<pre>smsComposeTask.show();</pre>

4. SearchTask :

Lets you open the shell search engine

SearchTask searchTask = new SearchTask();
searchTask.SearchQuery = "Windows Phone 7";
searchTask.Show();

5. MediaPlayerLauncher:

Will Trigger the Phone’s Media Player Application

MediaPlayerLauncher mediaPlayerLauncher = new MediaPlayerLauncher();
mediaPlayerLauncher.Media = new Uri("vs_logo2010_WMV9_640x360.wmv", UriKind.Relative);
mediaPlayerLauncher.Show();

6. WebBrowserTask:

The WebBrowserTask will let you trigger the phone’s IE mobile browser and redirect the user to the page specified.

WebBrowserTask webBrowserTask = new WebBrowserTask();
webBrowserTask.URL = "http://developer.windowsphone.com";
webBrowserTask.show();

I was not able to find much detail on these Launchers. Folks reading this block can contribute.:

7.MarketplaceDetailTask:

From the Name of it seems, it will launch the phone’s Marketplace app and show details. Not used this one.

8. MarketplaceHubTask:

Launches the Marketplace Hub, i guess. I don’t think we will be able to test this on the locked emulator.

9. MarketplaceReviewTask

10. MarketplaceSearchTask

I will be posting the next post on using the Choosers and will also post the entire solution for your ready reference. Once again, thanks for your support and keep looking at this space for more Windows Phone 7 related posts.

About these ads

Written by sudheerkovalam

August 6, 2010 at 3:02 am

5 Responses

Subscribe to comments with RSS.

  1. [...] I had described Windows Phone 7 launchers here. [...]

  2. Hi,

    Thx for your article!
    In the smsComposeTask-Part there is the smsComposeTask.Show() missing.

    BR,
    A

    Andi

    December 31, 2010 at 12:50 pm

    • My bad… Will correct it …
      Thanks for pointing it out Andi ..

      sudheerkovalam

      December 31, 2010 at 3:46 pm

  3. [...] and Choosers in Windows Phone 7 – part 1 , part [...]

  4. [...] Let us continue our exploration of Windows Phone 7 Launchers and Choosers. I had described Windows Phone 7 launchers here. [...]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: