Code to Make Call in Windows Phone 7

Launchers are used to perform tasks provided by the  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,

SMS in Windows Phone7

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

using Microsoft.Phone.Tasks;

Then create an instance of PhoneCallTask.

PhoneCallTask callTask = new PhoneCallTask();

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

  1. PhoneNumber
  2. DisplayName

So first set PhoneNumber property as below,

callTask.PhoneMunber = "999999";

And DisplayName as below,

callTask.DisplayName = "debugMode";

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

callTask.Show()

If you put all code together and want to send SMS 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,

Windows Phone7

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

Windows Phone 7 SMS

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

Windows Phone 7 call

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

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.

Up Next
    Ebook Download
    View all
    Learn
    View all