我正在使用Windows手机应用程序搜索联系人,然后根据他们的移动运营商对其进行分类,因此它基本上搜索电话号码的前3位数字,以告知它属于哪个运营商,然后将它添加到列表,任何指导如何做到这一点,因为我完全是noob并通过反复试验,谢谢。
答案 0 :(得分:1)
您可以使用Microsoft.Phone.UserData.Contacts类读取现有的联系人数据。以下是示例代码:
private void ButtonContacts_Click(object sender, RoutedEventArgs e)
{
Contacts cons = new Contacts();
//Add an event handler for SearchCompleted event
cons.SearchCompleted += new EventHandler<ContactsSearchEventArgs>(Contacts_SearchCompleted);
//Read existing contacts, FilterKind.None will return all contacts
cons.SearchAsync(String.Empty, FilterKind.None, "Contacts Test #1");
}
void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs args)
{
//Do something with the results
//Following code simply prints the phone numbers
foreach (Contact contact in args.Results)
foreach (ContactPhoneNumber phoneno in contact.PhoneNumbers)
Debug.WriteLine(phoneno.PhoneNumber);
}
您需要在WMAppManifest.xml中为ID_CAP_CONTACTS添加功能声明。