Click here to Skip to main content
13,289,242 members (60,602 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


Posted 12 Apr 2012

How to Call a Number in WP7 using the PhoneCallTask?

, 12 Apr 2012
Rate this:
Please Sign up or sign in to vote.
How to call a number programmatically in Windows Phone

Previously, we learnt “How to Save a Phone Number in WP7 using the SavePhoneNumberTask?”. There, we discussed the basics of the API and details about the implementation stuff with step-by-step details.

Today, in this small blog post, we will learn how to call a number programmatically in Windows Phone 7 by using the PhoneCallTask API. We will also know what the limitations are of this API class. Continue reading to know further.

Know About the API

Like other phone tasks, PhoneCallTask is also a sealed class present inside the Microsoft.Phone.Tasks namespace. It exposes two properties called DisplayName and PhoneNumber of type string. The Show() method shows the phone application where it confirms the user whether to dial or not.

Here is the meta data of PhoneCallTask:

namespace Microsoft.Phone.Tasks
    public sealed class PhoneCallTask
        public string DisplayName { get; set; }
        public string PhoneNumber { get; set; }

        public void Show();

Here is the internal implementation of the Show() method call:

public void Show()
    if (!ChooserHelper.NavigationInProgressGuard((Action) (() => this.Show()))) return;
    ThreadPool.QueueUserWorkItem(new WaitCallback(PhoneCallTask.PhoneDial), (object) this);

private static void PhoneDial(object phoneCallTask)
    PhoneCallTask phoneCallTask1 = phoneCallTask as PhoneCallTask;
    string phoneNumber = phoneCallTask1.PhoneNumber;
    string displayName = phoneCallTask1.DisplayName;

I hope that the above internal code will help you to understand the actual implementation of the API which exposes by the SDK for the developers.

Implementation Steps

The implementation steps of PhoneCallTask in your application is really very simple. Just create the instance of the class by populating the properties and call the Show() method as shown in the below code snippet:

var phoneCallTask = new PhoneCallTask
                            DisplayName = "Kunal Chowdhury",
                            PhoneNumber = "0208795446322"

The property called “PhoneNumber” is required to dial the number using the PhoneCallTask. You can skip “DisplayName” but “PhoneNumber” is mandatory.

Screenshot 1: How to Call a Number in WP7 using the PhoneCallTask?     Screenshot 2: How to Call a Number in WP7 using the PhoneCallTask?


There are some limitations of this class for security purposes. Using PhoneCallTask, you can dial any number except any special numbers or service codes, e.g., Balance Check like *111*1#.

To check it out, set the PhoneNumber property to any special numbers like: *111*1# and call the Show() method as shown in the below code snippet:

var serviceCallTask = new PhoneCallTask
                              DisplayName = "Balance Check", 
                              PhoneNumber = "*111*1#" // service call number

When you run the code, you will notice the below screen if you dial the number from the code:

Screenshot 3: How to Call a Number in WP7 using the PhoneCallTask?

This limitation is made to protect the user from any security hole from any application installed from 3rd party.

I hope that this post was helpful to you to understand the basics and implementation of the API. If you like these posts, don’t forget to share with your friends, colleagues or others for whom you believe this post will be useful. Don’t forget to share your feedback as it will help me to improve my future posts and also encourage me to deliver more for the benefit of you.

Stay tuned to my blog, Twitter, or Facebook to read more articles, tutorials, news, tips & tricks on various technology fields.


You may like to follow me on Twitter @kunal2383 or may like the Facebook page of my blog


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Kunal Chowdhury «IN»
Software Developer (Senior)
India India
Kunal Chowdhury is a Microsoft "Windows Platform Development" MVP (Most Valuable Professional), a Codeproject Mentor, Telerik Developer Expert, Nokia Developer Champion, Windows 10 Champion, Microsoft Rockstar, Speaker in various Microsoft events, Author, passionate Blogger and a Software Engineer by profession.

He is currently working in an MNC located in India. He has a very good skill over XAML, C#, Silverlight, Windows Phone, WPF and Windows Store (WinRT) app development. He posts his findings, articles, tutorials in his technical blog and CodeProject.

Book authored:

Connect with me on:

My CodeProject Awards/Prizes:

You may also be interested in...


Comments and Discussions

QuestionFormatting of the code blocks Pin
Mika Wendelius11-Apr-12 19:12
mvpMika Wendelius11-Apr-12 19:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171207.1 | Last Updated 12 Apr 2012
Article Copyright 2012 by Kunal Chowdhury «IN»
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid