我正在根据我在MSDN中阅读的链接使用以下代码。
请指出我的代码中的问题。
需要注意的事项: 我正在使用 Windows 8.1 通用应用程序模板。 我也已将联系人和约会添加到了我的应用程序功能中。
在我看来一切看起来都很完美...如果我漏掉了什么,请帮忙指出!
public async void getFavouriteList()
{
try
{
ContactStore store = await ContactStore.CreateOrOpenAsync();
var queryOptions = new ContactQueryOptions();
queryOptions.DesiredFields.Add(KnownContactProperties.DisplayName);
ContactQueryResult result = store.CreateContactQuery(queryOptions);
var contactCount = await result.GetContactCountAsync();
var contacts = await result.GetContactsAsync(0, contactCount);
//IReadOnlyList<StoredContact> contacts = await result.GetContactsAsync();
foreach (StoredContact item in contacts)
{
// I am not getting any contacts so this debug line is not printed !!!
Debug.WriteLine("this is not printed");
Debug.WriteLine(item.DisplayName + ":" + item.RemoteId);
}
}
catch(Exception e)
{
Debug.WriteLine("this is not printed 7");
Debug.WriteLine(e.Message);
}
}
请指出我的代码中的问题。
需要注意的事项: 我正在使用 Windows 8.1 通用应用程序模板。 我也已将联系人和约会添加到了我的应用程序功能中。
在我看来一切看起来都很完美...如果我漏掉了什么,请帮忙指出!