Favourite Pages

Monday, 17 February 2014

Choosers and Launchers



Having used a windows phone, most of the times, a user’s needs to perform some common tasks while using some applications, this had been made possible by the presence of Launchers and Choosers in the Windows Phone.
The Launcher and Chooser APIs invoke distinct built-in applications that replace the currently running application. When implemented correctly, the Launchers and Choosers framework can provide the end user with a seamless experience in which it is not apparent that the user is switching between applications.
All Tasks that are available in Windows Phone 8 can be found in the Microsoft.Phone.Tasks namespace thus its rommended to include this namespace when using any of the Task classes.
A.                     Launchers
In simple words, a launcher simply takes the user to another part of the phone experience to accomplish some goal (for example, launch a web page, make a phone call, and so on). Launcher is an API that launches one of the built-in applications, such as the Contacts application or the web browser, through which the user completes a task.
When the new application appears, the user can choose to complete or cancel the task. When the user closes the new application, the calling application is usually reactivated. 
Windows Phone 8 added support for the following new launchers:
a.     SaveAppointmentTask – This launcher is used to display a new appointment in the user’s calendar to enable users to add appointments to their calendar from a Windows Phone 8 application.
b.    MapDownloaderTask – This launcher is used to allow users to launch the Maps settings application to enable users to download map data for offline use.
c.     MapsTask – This launcher is used to allow a user to display a map with the user’s current location as the center.
d.    MapsDirectionsTask – This launcher is used to display driving directions.
e.     ShareMediaTask – This launcher is used to allow users to share media on social networks.
Besides these new launchers, the previous generation launchers are also supported on Windows Phone 8.
·       EmailComposerTask: launches the Email application and displays a new email message
·       MarketplaceDetailTask: launches the Windows Phone Marketplace client application which then shows the details page for a product specified by the unique identifier you provide.
·       MarketplaceHubTask: launches the Windows Phone Marketplace client application.
·       MarketplaceReviewTask: launches the Windows Phone Marketplace client application which then displays the review page for your application.
·       MarketplaceSearchTask: launches the Windows Phone Marketplace client application which then shows the search results based on search terms you provide.
·       MediaPlayerLauncher: launches the Media Player application and plays the media file you specify.
·       PhoneCallTask: launches the Phone application and displays the specified phone number and display name.
·       SearchTask: launches the Search application and performs search query you provide.
·       SmsComposerTask: launches the Messaging application which displays a new SMS message.
·       WebBrowserTask: launches the Web browser and displays the URL you provide.
For one to come up with an application that users the launchers, one needs to:-
       i.            Create an instance of the task type for the Launcher.
     ii.            Set any required and optional properties of the task object. These determine the behavior of the task application when it is invoked.
  iii.            Call the Show method of the task object.




B.                      Choosers
 A chooser takes the user to a facility on the phone but returns to the app with some information (for instance, choose an email address, take a picture, and so on). A Chooser is an API that launches one of the built-in applications, such as the Contacts application or the camera, through which the user completes a task.
When the user starts the new application, it appears on the screen and the user can choose to complete or cancel the task. When the user closes the new application, the calling application is usually reactivated and supplied with data and status. 
List of Choosers on Appendix B.
When build an application that user’s chooser task, you are supposed to:-
                   i.            Create an instance of the task type for the Chooser.
                 ii.            Identify the callback method to run after the user completes the task.
              iii.            Set any required and optional properties of the task object.
              iv.            Call the Show method of the task object.
                 v.            Implement the completed event handler to capture data and status after the user completes the task.
Developing the App:
To build a sample application that supports some of these tasks, let’s use our basic knowledge in page navigation and creating event using buttons.
Steps:
Create a new Windows Phone 8 Application and name it ‘PartFive’. On the Display Layout, add two buttons and name them, ‘LauncherButton’ and ‘ChooserButton’ respectively and create an event for each, also change the content for each button to be ‘launcher’ and ‘Chooser’ respectively.
On the solution bar, press ‘Ctrl+shift+A’  to create a new portrait page, name the Page as ‘LanuchersPage’ and also create another Windows Phone Application Portrait Page and name it ‘ChoosersPage’.

Step 1. Creating a new Project

Step 2. Choosing Windows Phone Application


Step 3: Adding buttons and their event

Step 4: Adding the events for launchers ad choosers on the mainpage.xaml.cs

Nb: For adding media, Right click on the project in the solution Window and add a new Folder and name it ‘media’.

For the Launcher media, Drag and drop your music and remember to keep in mind the extension name!!!!

Keep in mind, the email launcher requires you to have set a Microsoft account from which it selects any of the account you have, to test the launcher you need to use a device.
For the Chooser, drag and drop an image control from the toolbox on the Left panel on your sdk.
Pdf
Kamiri Peterson M,
Game & Software Developer, Tutor & Mentor.

Quick Links: www.kapes.yolasite.com 
Nokia Store Links: Nokia Store 
Windows Store Links: Windows Store