简体   繁体   中英

Phone Call Task Error on WP8

I have a problem with debug my app.There is no eror, I debug the app on device it start's but when I tap the button debug error! that's how i use it:

In .xaml file:

<Button Name="taxi1" Content="Call Taxi 1" Click="taxi1_Click" />

in .xaml.cs file:

private void taxi1_Click(object sender, RoutedEventArgs e)
 {
 PhoneCallTask call = new PhoneCallTask();
call.DisplayName = "Calling Taxi 1";
  call.PhoneNumber = "1411111";
call.Show();
 }

and i added:

using Microsoft.Phone.Tasks;

I think what I'm doing it wrong is that i use this function for several times the only thing that is changing is the name of taxi:

private void taxi2 _Click (....)

and the call.DisplayName=" Calling Taxi 2 ";

and call.PhoneNumber = " 1422222 ";

Maybe I should use only one function like

        private void PhoneCall_Click(object sender, RoutedEventArgs e)
         {
          string number="";
          HttpUtility.UrlEncode((sender as Button).Tag.ToString());
    if (NavigationContext.QueryString.TryGetValue("number", out number))
        {
            if (!string.IsNullOrWhiteSpace(number))
            {
         PhoneCallTask call = new PhoneCallTask();
        call.DisplayName = "Taxi";
          call.PhoneNumber = number;
        call.Show();
         }
}
}

and <Button ....... Tag="141111" .. />

just one thought, do you have permission added in manifest for this to work ? if so, writing what error is actually being thrown would be helpful in order to help you

应添加ID_CAP_PHONEDIALER

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