PhoneCallHistoryStore store = await PhoneCallHistoryManager.RequestStoreAsync(PhoneCallHistoryStoreAccessType.AllEntriesLimitedReadWrite);
PhoneCallHistoryEntryQueryOptions options = new PhoneCallHistoryEntryQueryOptions() { DesiredMedia = PhoneCallHistoryEntryQueryDesiredMedia.All };
PhoneCallHistoryEntryReader reader = store.GetEntryReader(options);
var logs = await reader.ReadBatchAsync();
此处logs.Count
始终为20。
如何获取所有日志?
答案 0 :(得分:2)
是的,这是正确的行为。在方法名称中,您可以看到Batch
。这意味着你接听了一部分电话(20项)。要获取所有呼叫,请使用以下代码:
PhoneCallHistoryStore store = await PhoneCallHistoryManager.RequestStoreAsync(PhoneCallHistoryStoreAccessType.AllEntriesLimitedReadWrite);
PhoneCallHistoryEntryQueryOptions options = new PhoneCallHistoryEntryQueryOptions() { DesiredMedia = PhoneCallHistoryEntryQueryDesiredMedia.All };
PhoneCallHistoryEntryReader reader = store.GetEntryReader(options);
var phoneCallHistoryEntries = new List<PhoneCallHistoryEntry>();
var hasItems = true;
do
{
var logs = await reader.ReadBatchAsync();
phoneCallHistoryEntries.AddRange(logs);
hasItems = logs.Count > 0;
}
while (hasItems);