简体   繁体   中英

Make a phone call In Windows 10 mobile

I writing app for Windows 10 Mobile

I need to call Phone Task, when I tap a button.

I try to do it like this

 private void TelephoneButton_Click(object sender, RoutedEventArgs e)
    {
        var phoneCallTask = new PhoneCallTask
        {
            PhoneNumber = "+380442308888",
            DisplayName = "The Name goes here"
        };

        phoneCallTask.Show();

    }

and using this using Microsoft.Phone.Tasks;

But I have this error in using Error CS0234 The type or namespace name 'Phone' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

and this in PhoneCallTask

Error   CS0246  The type or namespace name 'PhoneCallTask' could not be found (are you missing a using directive or an assembly reference?)

What's wrong and how I can call Phone Task?

You need to use PhoneCallManager . A reference is needed to Windows.Foundation.UniversalApiContract .

Then you could do something like this:

private void TelephoneButton_Click(object sender, RoutedEventArgs e)
{
    Windows.ApplicationModel.Calls.PhoneCallManager.ShowPhoneCallUI("+380442308888", "The Name goes here");
}

Update add a reference 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM