Floating FB popout byF5debug

101 How to on Windows Phone – How to #6 – Play with Phone Call Task for Windows Phone

 

In this how to tutorial we are going to see how to use a Phone Call Task which providers users to launch the phone call from the application which we are going to develop. Basically we can use this Launcher (Check this article to get clear idea on What Launchers are and What are the different Launcher tasks available with Windows Phone Working with Launchers in WP7 ) to launch the phone application and display a phone number with the display name which we can set programmatically. This launcher will just provide the necessary information to the phone application, but the phone call will not be places unless and until we press the call button.    [more]

Let us see the steps and code on how to use this task in real time.

Open Visual Studio 2010 IDE and create a new Silverlight for Windows Phone project with a valid project name as shown in the screen below. Once the project is created add some controls which are used to trigger the Phone Call Task.

clip_image002

Now let us make some changes to the UI, which on button clicks will launch the Place Call Phone Application. We are going to add a button which will trigger the phone call task. Once we added the button, in the code behind we need to start with the code. Phone Call Task has the assembly Microsoft.Phone.Task as the namespace, which is needed to be added in the using statement as below code.

using Microsoft.Phone.Tasks;

The screen looks like below where we have a button which is our application scope, clicking on it will launch the task. Basically we provide a default option of call home, but in the code we will play around and write in such a way it will take the display name and the dial number programmatically as shown in the screen below.

clip_image004

Microsoft.Phone.Task.PhoneCallTask has the below set of properties which are used to play around with the placing call in the Phone call application basically which place a call to the specified number and shows the display name which we specify.

S No

Property Name

Description

1

DisplayName

Name that is displayed while placing the call

2

PhoneNumber

Number that is dialed while application is launched

Now in the button click event we need to play around with the code as shown below.

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;

namespace F5debugWp7PhoneCallTask
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            PhoneCallTask f5debugPhoneTask = new PhoneCallTask();

            f5debugPhoneTask.PhoneNumber = “1234567890″;
            f5debugPhoneTask.DisplayName = “Sweet Home”;

            f5debugPhoneTask.Show();
        }
    }
}

Since we are going to run the application in the Emulator, it uses the FAKE GSM and a false SIM Card. If in the device the sim card is not available it will prompt the user to add one by default. Now let us run the application and see the expected results.

Output:

clip_image006

Now let us play around still and see how to put a conference call with the call we placed using our code, this is straight forward just clicking on add call and enter the phone number to make the conference. The initial call will be on hold and once second call is connected we need to click on Merge Call to make the conference with both the numbers as shown in the screens below.

clip_image008

We can remove a particular member from the conference by clicking on Private in the list and opt the user to get out of the call as shown in the screen below. Clicking on Private will get the below list first from which we can select the call. Once the call is selected we need to click on End Call to close the call and move with the preferred call alone.

clip_image010

Thanks for reading this tutorial and providing continuous support. If you like my blog and if you are interested in getting the latest updates on new articles, kindly follow me through one of these options.

About Author: Karthikeyan Anbarasan, Microsoft MVP (Most Valuable Professional) in ASP.NET/IIS Architecture. He is the Founder and Chief Editor of the www.f5debug.net website and has authored books on Windows Phone and Business Intelligence(SSIS). He is also a Passionate Speaker and a Blogger on Microsoft Technologies.

You can Join Me On: Facebook, Twitter, Google Plus, LinkedIn

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Recent Posts

Random Posts

Most Viewed

URL Shortner

Create your own short urls!!!

Site Counter

free counters

Disclaimer

This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet. I have documented my personal experience on this blog.

Protected by Copyscape Web Plagiarism Finder

Site Meter