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.
            Asked
            
        
        
            Active
            
        
            Viewed 108 times
        
    2 Answers
1
            
            
        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.
 
    
    
        Raz Harush
        
- 739
- 1
- 6
- 21
1
            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();
 
    
    
        Community
        
- 1
- 1
 
    
    
        Stefan Wexel
        
- 1,154
- 1
- 8
- 14
- 
                    Wow, very comprehensive and exactly what I was looking for. Thank you very much! – Jun 21 '13 at 09:43
