I hope you like my earlier article on EQATEC Profiler for Windows Phone 7. Today I am going to discuss on another interesting topic as ‘Launchers’.This is very important topic from application development perspective which will allow developers to use some phone specific functionality like Calling, Sending SMS via application which can be either done with functions who are built in the phone.
As per MSDN,Launchers defined as :
A Launcher is an API that launches one of the built-in applications through which a user completes a task, and in which no data is returned to the calling application.
There are many scenarios in which you need to integrate the Calling,SMS etc which are default features of the device but since it’s a sandbox modal you might not be able to grab that directly,Hence APIs comes into picture and this is how Launchers becomes unique for your Windows Phone 7 Application.
Launchers usually take parameters and execute tasks, Their job is not to return something back to the application since we always invoke them with some parameters which we want to process with specific task.Hence you will not find any thing getting return back to the application.This is the default behavior of Launchers.There are several types of launchers however today I am not going to talk much on Marketplace Task etc since its totally a different topic and I will address that in future. Today I am going to cover basic Tasks like Calling, Sending SMS, Search Task and WebBrowser Task etc.This is very useful in case you want build some notification or alert message sending app.
Lets see the Coding part here,I am taking simple Listbox having items as various Launchers or Tasks which can be used from underline API.
XAML Code :
<ListBox x:Name="lstLaunchers" SelectionChanged="lstLaunchers_SelectionChanged">
<ListBoxItem x:Name="lstmphcall" FontSize="24" Content="Phone Call Task"/>
<ListBoxItem x:Name="lstmsms" FontSize="24" Content="SMS Task"/>
<ListBoxItem x:Name="lstmemail" FontSize="24" Content="E-mail Compose Task"/>
<ListBoxItem x:Name="lstmsearch" FontSize="24" Content="Search Task"/>
<ListBoxItem x:Name="lstmweb" FontSize="24" Content="Web Browser Task"/>
C# Code :
private void lstLaunchers_SelectionChanged(object sender, SelectionChangedEventArgs e)
PhoneCallTask phcalltsk = new PhoneCallTask();
phcalltsk.PhoneNumber = "+919122333444";
phcalltsk.DisplayName = "Vikram Pendse";
case 1 :
SmsComposeTask smscotsk = new SmsComposeTask();
smscotsk.To = "+919122333444";
smscotsk.Body = "Party @ Hard Rock Cafe 10 PM Onwards";
EmailComposeTask emlcotsk = new EmailComposeTask();
emlcotsk.To = "email@example.com";
emlcotsk.Body = "Hello, How are you doing? Can we meet on this weekend? Do reply, Vikram.";
emlcotsk.Cc = "firstname.lastname@example.org";
emlcotsk.Subject = "Hi!";
SearchTask sertsk = new SearchTask();
sertsk.SearchQuery = "XBox game trailers";
WebBrowserTask webrwtsk = new WebBrowserTask();
webrwtsk.URL = "http://www.microsoft.com”;
So this is how you can integrate Launchers in your application. I am calling each in my Switch() and each case represents each functionality like Calling,Sending SMS etc. Please make a note that since you are doing this on emulator which have some limited functionality,hence you might not able to see few things like email unless configuration is made which is limited due to emulator.
I demonstrated the simplest way,Now you must have understood that how easy it is to integrate in your app. See some of the output shots here which will give you feel of these Launchers.
Hope you will find this useful while building your apps. Media and Marketplace Task I am leaving to you to explore.I might not talk on Choosers in next post but soon I will cover that as well, I have few more interesting stuff in upcoming post. So be here and keep visiting this place.Lot more to come on Windows Phone 7 in coming days.