UserActivitySessionHistoryItem 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
提供使用者參與特定活動的開始和結束時間。
public ref class UserActivitySessionHistoryItem sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 393216)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class UserActivitySessionHistoryItem final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 393216)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class UserActivitySessionHistoryItem final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 393216)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class UserActivitySessionHistoryItem
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 393216)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class UserActivitySessionHistoryItem
Public NotInheritable Class UserActivitySessionHistoryItem
- 繼承
- 屬性
Windows 需求
裝置系列 |
Windows 10, version 1803 (已於 10.0.17134.0 引進)
|
API contract |
Windows.Foundation.UniversalApiContract (已於 v6.0 引進)
|
範例
private async void GetMostRecentActivity()
{
UserActivityChannel channel = UserActivityChannel.GetDefault();
// Gets the 10 most recently engaged UserActivity objects, sorted by engagement EndTime (null EndTimes sort first)
IList<UserActivitySessionHistoryItem> recentActivity = await channel. GetRecentUserActivitiesAsync(maxUniqueActivities: 10);
foreach (var activity in recentActivity)
{
var engagements = await channel.GetSessionHistoryItemsForUserActivityAsync(activity.UserActivity.ActivityId, new DateTimeOffset(DateTime.Now, TimeSpan.FromDays(1)));
long totalEngagementTime = 0;
foreach(var e in engagements)
{
if (e.EndTime != null) // EndTime may be null for active UserActivities
{
totalEngagementTime += e.EndTime.Value.Ticks - e.StartTime.Ticks);
}
// App specific code to display the activity engagement time
}
}
}
備註
許多應用程式提供最近使用的 (MRU) 清單。 這個類別提供 UserActivity 的開始和結束時間資訊,讓您可以為使用者活動提供類似的體驗。
屬性
EndTime |
取得使用者停止參與與此UserActivitySessionHistoryItem相關聯的UserActivity的時間。 |
StartTime |
取得使用者開始參與與此UserActivitySessionHistoryItem相關聯的UserActivity的時間。 |
UserActivity |
取得與此UserActivitySessionHistoryItem相關聯的UserActivity。 |