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 |