I want to retrieve the last call history entry in a Windows 10 mobile app (UWP), and I can do it with a high cost approach like below.
PhoneCallHistoryStore phoneCallHistoryStore = await PhoneCallHistoryManager.RequestStoreAsync(PhoneCallHistoryStoreAccessType.AllEntriesLimitedReadWrite);
PhoneCallHistoryEntryReader phoneCallHistoryEntryReader = phoneCallHistoryStore.GetEntryReader();
IReadOnlyList<PhoneCallHistoryEntry> phoneCallHistoryEntries = await phoneCallHistoryEntryReader.ReadBatchAsync();
PhoneCallHistoryEntry lastPhoneCallHistoryEntry = phoneCallHistoryEntries.FirstOrDefault();
As you know and describe in Getting call history returns only last 20 logs this approach per run retrieves 20 calls when I only want the last call, so I think I am paying a high cost for this and I retrieve 19 call unnecessarily.
Is there any better approach?
Getting a "batch" of calls at a time is the only way to get entries. If you think the method is too slow, you can provide feedback via the Feedback Hub's "Developer" category. But before you decide it is too slow, you need to define what "fast enough" is for your scenario, then measure the code against your goals with a profiler, and verify the slowness it's cause by this API (vs something else).