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
 

Chetan Gulati

Currently am doing B TECH in IT from Delhi Technological University. App development is my passion. Believe in quality rather than quantity.

  • Michael Costakis

    I’m working my way through the code now and have a couple of errors, but when I tried using the zipped example I got errors loading. I’m wondering if its potentially that I’m on Visual Studio 2017 and seems most the references were broken from the older version.

    You don’t happen to have done an updated version for this right?

Read more:
How to create your first Windows Phone app
How to change the App name and Tile name of your Windows phone app
Data binding in Windows Phone app – One way binding
Close