Question

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();
        }
    }
Was it helpful?

Solution

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

source

OTHER TIPS

This is how you should do it:

PhoneCallTask phoneCallTask = new PhoneCallTask();

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

phoneCallTask.Show();

Remember that the call is not automatically started but it prompts the user to confirm that action.

Here is how to initiate a call on windows phone

http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394025(v=vs.105).aspx

Ok for future reference i must add this.

If you get an Unauthorized Access Exception then you need to enable ID_CAP_PHONEDAILER from the Capabilities section in the WMAppManifest.xml file.

See here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top