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,它很容易爲我提供一個對象來區分數據到上面提到的字段中。 –