Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
How to make a Phone call in Windows Phone
This code example shows how to launch the Phone app using PhoneCallTaskAPI in Windows Phone.
Note: In contrast to Symbian, Windows Phone does not allow you to make calls "directly" from your own app, or to monitor for and connect to incoming calls. As soon as phone call initiation code below is executed the phone app will be displayed and the user will be asked to confirm that they want to dial the specified number.
This simple example displays a Phone Call button on the screen. When the button is pressed, the app calls PhoneCallTaskAPI in the Microsoft.Phone.Tasks namespace.
First create a new Windows Phone 7 Silverlight application using the default template in MS Visual Studio. Then add a Button to the XAML as shown below:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button Content="Phone Call" Height="82" HorizontalAlignment="Left" Margin="140,234,0,0"
Name="btnCall" VerticalAlignment="Top" Width="auto" Click="btnCall_Click" />
The user interface with the button is shown below:
Next initialize the PhoneCallTask task object in the constructor of page. To avoid the memory overhead so I initialized in the constructor.
PhoneCallTask phoneTask = null;// Constructor
phoneNumberChooserTask = new PhoneNumberChooserTask();
phoneNumberChooserTask.Completed += new EventHandler<PhoneNumberResult>(phoneNumberChooserTask_Completed);
phoneTask = new PhoneCallTask();
The PhoneCallTask class contains two core properties like DisplayName, PhoneNumber and one show() method, which allows us to show the phone application. To make an actual call though the application.
Double-click the button control and click event handler got added to button control object.On the button click event the device's native phonebook is launched & user can then select a contact from it to whom he wishes to make a phone call . See below mentioned code snippet.
private void btnCall_Click(object sender, RoutedEventArgs e)
//this will launch the phonebook to choose a contact to call.
As soon as user chooses the contact from phonebook, the following call back method gets called & launches the phone call dialog, asking the user to dial the particular contact or not.
void phoneNumberChooserTask_Completed(object sender, PhoneNumberResult e)
if (e.TaskResult == TaskResult.OK)
//Code to start a new phone call using the retrieved phone number.
phoneTask .DisplayName = e.DisplayName;
phoneTask .PhoneNumber = e.PhoneNumber;
Following screenshots depict the same :
Download source code File:WP MakeACall.zip.
Basically PhoneCallTask API allows to launch the Phone application.
- PhoneCallTask (MSDN)