Getting call history returns only last 20 logs

冷暖自知 提交于 2020-01-15 03:44:06

问题


PhoneCallHistoryStore store = await PhoneCallHistoryManager.RequestStoreAsync(PhoneCallHistoryStoreAccessType.AllEntriesLimitedReadWrite);
PhoneCallHistoryEntryQueryOptions options = new PhoneCallHistoryEntryQueryOptions() { DesiredMedia = PhoneCallHistoryEntryQueryDesiredMedia.All };
PhoneCallHistoryEntryReader reader = store.GetEntryReader(options);
var logs = await reader.ReadBatchAsync();

Here logs.Count is always 20.

How can I get all the logs?


回答1:


Yes, it's the correct behavior. In method's name you can see Batch. It means that you take part of calls (20 items). For getting all calls use the following code:

    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);


来源:https://stackoverflow.com/questions/36107562/getting-call-history-returns-only-last-20-logs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!