Search code examples
windows-phone-8phone-call

Trigger a phone call in Windows Phone 8 application


I need to develop an app to make a call from the Windows Phone 8 app using Visual Studio.
But I couldn't find any resources to do it.
When a button is clicked I need to call to a mobile number which is already given.
By clicking that button I must call only to that mobile number.

This is what I coded. When a given button is clicked, I this method is calling...

 private void HyperlinkButton_Click_1(object sender, RoutedEventArgs e)
    {
        PhoneCallTask phoneCallTask = new PhoneCallTask();

        phoneCallTask.PhoneNumber = "0719957868";
        phoneCallTask.DisplayName = "Gage";

        phoneCallTask.Show();
    }

But I get an unhandled exception.

Unhandled exception.

    // Code to execute on Unhandled Exceptions
    private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
    {
        if (Debugger.IsAttached)
        {
            // An unhandled exception has occurred; break into the debugger
            Debugger.Break();
        }
    }

Solution

  • When you use PhoneCallTask, you have to specify a new Capability of your app in WMAppManifest.xaml: ID_CAP_PHONEDIALER

    source