【问题标题】:Getting call history returns only last 20 logs获取通话记录仅返回最近 20 条日志
【发布时间】:2016-07-06 13:49:34
【问题描述】:

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。

如何获取所有日志?

【问题讨论】:

    标签: uwp win-universal-app windows-10-mobile


    【解决方案1】:

    是的,这是正确的行为。在方法的名称中你可以看到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);
    

    【讨论】:

    • 非常感谢您的确认。我实际上已经尝试过再次调用它,但不知道我如何再次得到相同的结果。看完你的回答我又试了一次,果然奏效了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-02
    • 2014-03-10
    相关资源
    最近更新 更多