0

I have some plain contacts in my phone and I have also configured facebook,google and hotmail in my phone. In my native people hub I can see my phone contacts as well my facebook contacts and others too. I want to get information of all contacts that have phone number. How I can get that from WP7 contacts api.

        var Contacts = new Microsoft.Phone.UserData.Contacts();

        // hook up an event handler to retrieve the contacts after we've searched for them on the WP7
        Contacts.SearchCompleted += ContactsSearchCompleted;

        //Start the search asynchronously.
        Contacts.SearchAsync(String.Empty, FilterKind.None, null);
4

1 回答 1

0

以这种方式搜索并不是特别适合搜索具有值的联系人,而是搜索具有特定值的联系人。

您可以对单个字符进行多次搜索(使用该FilterKind.PhoneNumber选项),然后将它们组合起来。

获得所有结果(就像您在代码中一样)然后直接查询它们可能会容易得多。

就像是:

foreach (var contact in e.Results)
{
    if (contact.PhoneNumbers.Count() > 0)
    {
        // This contact has at least 1 phone number. 
        // Do something approrpiate with it
    }
}
于 2012-09-04T10:30:36.483 回答