Launchers and choosers – Phone number tasks in Windows phone app

This is the third blog post of this series in which I am going to talk about different Phone number tasks in Windows phone app.

In this post I shall be discussing about five different tasks

1. SavePhoneNumberTask

2. PhoneNumberChooserTask

3. PhoneCallTask

4. SmsComposeTaks

5. SaveContactTask

 

1. First create a new Project having the name Phonenumbertasks.

 


 

2. Before going further add the following Namespace required for the above tasks.

 

 

SavePhoneNumber Task

It launches the contacts application and saves the provided phone number to the Contacts list. This is done by calling

the Show method of the SavePhoneNumberTask object. You can obtain the result of the chooser operation by handling the Completed event.

Create a button on the MainPage to launch the task and check its result in task completed event handler. The code for the click event handler of this button is given below.

 

 

The code for Task completed event Handlers is as follows.

 

 


 

Phonecall Task

Making a phone call is just so easy with the PhoneCallTask .It launches a Phone app that will enable users to make a phone call from your application.

Create a button on the MainPage to launch the task. The code for the click event handler of this button is given below.

 

 

Note: Whenever using PhoneCallTask remember to add the Following Capabilities in WmAppManifest.xml.

The capability required for phone call is ID_CAP_PHONEDIALER.

Otherwise it will give an Exception.

 


 


 

SmsComposeTask

Composing and sending sms can be done with the SmsComposeTask which launches the Messaging application which displays a new sms message. It expects a phone number which could be provided just as a string, but in-real world application user expect to select it from his contacts and if not found enter manually.

Create a button on the MainPage to launch the task and check its result in task completed event handler. The code for the click event handler of this button is given below.

 

 


 

PhoneNumberChooser Task

PhoneNumberChooserTask launches the Contacts application and allows the user to select a contact’s phone number. If the contact has multiple phone numbers, you have to select one of the them.

Create a button on the MainPage to launch the task and check its result in task completed event handler. The code for the click event handler of this button is given below.

 

 

The code for Task completed event Handlers is as follows.

 

 

SaveContact Task

You can easily save a new contact on your phone with the help of SavecontactTask. It has got different properties which can be left null. But the essential ones are described below.

Create a button on the MainPage to launch the task. The code for the click event handler of this button is given below.

 

 



 
I hope this post will be helpful to you. You can download the full project source file from the link given below.

 
Dowload full project file Phonenumbertasks.zip