获取通话记录 returns 仅最近 20 条记录
Getting call history returns only last 20 logs
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。
如何获取所有日志?
是的,这是正确的行为。在方法名中可以看到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);
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。
如何获取所有日志?
是的,这是正确的行为。在方法名中可以看到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);