Bagikan melalui


UserActivitySessionHistoryItem Kelas

Definisi

Menyediakan waktu mulai dan berakhir pengguna terlibat dalam aktivitas tertentu.

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
Warisan
Object Platform::Object IInspectable UserActivitySessionHistoryItem
Atribut

Persyaratan Windows

Rangkaian perangkat
Windows 10, version 1803 (diperkenalkan dalam 10.0.17134.0)
API contract
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v6.0)

Contoh

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
        }
    }
}

Keterangan

Banyak aplikasi menyediakan daftar yang paling baru digunakan (MRU). Kelas ini menyediakan informasi waktu mulai dan berakhir tentang UserActivity sehingga Anda dapat memberikan pengalaman serupa untuk aktivitas pengguna.

Properti

EndTime

Dapatkan waktu ketika pengguna berhenti terlibat dalam UserActivity yang terkait dengan UserActivitySessionHistoryItem ini.

StartTime

Dapatkan waktu ketika pengguna mulai terlibat dalam UserActivity yang terkait dengan UserActivitySessionHistoryItem ini.

UserActivity

Mendapatkan UserActivity yang terkait dengan UserActivitySessionHistoryItem ini.

Berlaku untuk