user818700
user818700

Reputation:

Access to Phone Call Feature on Windows Phone

Is it possible from your Windows Phone 7/8 application to get access to the phone call feature? I.e. if I have a string that contains a phone number, I'd like to send the user straight to the "phone" app with the number ready.

Upvotes: 0

Views: 111

Answers (2)

Stefan Wexel
Stefan Wexel

Reputation: 1154

If your string is a phone number, you can simply use the code below. If your string contains a phone number you first have to extract it.

I use a regex for that. You can use my code below but you might need to change something depending on the format of your strings:

public static String GetFirstPhoneNumber(String includesnumber)
    {
        MatchCollection ms = Regex.Matches(includesnumber, @"([0-9][^A-Z^a-z]+)([A-Za-z]|$)");
        Regex digitsOnly = new Regex(@"[^\d]");
        for (int i = 0; i < ms.Count; i++)
        {

            String res = digitsOnly.Replace(ms[i].Value, "");
            if (res.Length > 5)
                return res;
        }
        return "";
    }

You can read more about that here: A comprehensive regex for phone number validation

Here the actual PhoneCallTask:

Microsoft.Phone.Tasks.PhoneCallTask t = new Microsoft.Phone.Tasks.PhoneCallTask();
                t.PhoneNumber = numbertocall;
                t.DisplayName = displayname;
                t.Show();

Upvotes: 1

Raz Harush
Raz Harush

Reputation: 739

Check out 'How to use the phone call task for Windows Phone' guide at the MSDN website, I believe that's what you're looking for.

Upvotes: 1

Related Questions