1
我使用Xamarin.Mobile组件为Android获取使用的代码联系人:Xamarin.Mobile联系人API占用了大量的时间,同时获取联系人?
var book = new AddressBook (Activity) {PreferContactAggregation = true};
var contData = data.Data;
var cur = Activity.ManagedQuery (contData, null, null, null, null);
Contact myContact = null;
var lookupKeyList = new List<string>();
while (cur.MoveToNext()) {
lookupKeyList.Add (cur.GetString (cur.GetColumnIndexContactsContract.Contacts.InterfaceConsts.LookupKey)));
}
myContact = book.Where (c => c.Id == lookupKeyList [0]).First();
此代码是选择从电话簿中的联系人和接收上OnActivityResult方法的部分数据。 不幸的是,这段代码是占用了太多的时间在某些设备上,是对他人瞬间。我猜它与联系汇总有关,但我不确定。任何指针?
我可以在这里使用的投影,但我需要区分接收到办公电话,住宅电话,工作电子邮件,家庭电子邮件等数据在我上面使用的代码,我只是得到了LookupKey场,并用它来获得接触来自Xamarin.Mobile Contacts API,它很容易为我提供一个对象来区分数据到上面提到的字段中。 –