Launchers are used to perform task provided by phone operating system. Making Call is feature of Windows phone operating system and can be used by Launcher API. PhoneCallTask launcher is used to call. This launcher class is defined as below,

image

 

To work with PhoneCallTask, first you need to add namespace of Microsoft.Phone.Task

image

Then create instance of PhoneCallTask.

image

Next you need to set values properties to make the call. To make the call you need to set below properties

  • PhoneNumber
  • DisplayName

So first set PhoneNumber property as below,

image

And DisplayName as below,

image

Last step you need to launch making call application provided by operating system. You can show that as below,

image

If you put all code together and want to make a call on click event of button then full code will be as below,

 


using System.Windows;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;

namespace Day6
{
public partial class MainPage : PhoneApplicationPage
{

public MainPage()
{
InitializeComponent();
}

private void btnCall_Click(object sender, RoutedEventArgs e)

{
PhoneCallTask callTask = new  PhoneCallTask();
callTask.PhoneNumber = "999999";
callTask.DisplayName = "debugMode";
callTask.Show();

}

}
}

 

When you run above code you will get application running as below,

image

When you click on Call button, you will next screen as below for confirmation to call.

image

After choosing Call you will get usual Windows Phone 7 Call screen as below,

image

If you want you can very much end call, turn on speaker, mute hold or add call. I hope this post was useful. Thanks for reading Smile

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

Advertisements

6 thoughts on “Code to make call in Windows Phone 7

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s