Xamarin读取手机联系人

if (CrossContacts.Current.Contacts != null) {
    var result = CrossContacts.Current.Contacts.ToList();
    var contacts = result.Where(c => !string.IsNullOrEmpty(c.LastName) && c.Phones.Count > 0);
    foreach(var contItems in result)
    {
        if (contItems != null) {
            if (contItems.Phones.Count > 0) {
                for (int i = 0; i < contItems.Phones.Count; i++)
                {
                    var item = new Models.ContactsModel();
                    if (!string.IsNullOrEmpty(contItems.Phones[i].Number)) {
                        item.TelPhoneNumberStr = contItems.Phones[i].Number;
                    }
                    item.NameStr = string.IsNullOrEmpty(contItems.DisplayName) ? "" : contItems.DisplayName;
                    BaseContactslist.Add(item);
                }
            }
        }
    }
}

阅读更多
换一批

没有更多推荐了,返回首页