Udostępnij za pośrednictwem


UserActivity Class

Definition

A UserActivity is created by an app during its execution to notify the system of a user work stream that can be continued on another device, or at another time on the same device. It provides information about a task the user is engaged in.

Note

Starting in July 2021, users who have activity history synced across their Windows devices through their Microsoft Account (MSA) will no longer have the option to upload new activity in Timeline. They'll still be able to use Timeline and see their activity history (information about recent apps, websites and files) on their local PC. AAD-connected accounts won't be impacted.

public ref class UserActivity sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 327680)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class UserActivity final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 327680)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Activatable(Windows.ApplicationModel.UserActivities.IUserActivityFactory, 393216, "Windows.Foundation.UniversalApiContract")]
class UserActivity final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 327680)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Activatable(Windows.ApplicationModel.UserActivities.IUserActivityFactory, 393216, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class UserActivity final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 327680)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class UserActivity
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 327680)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.ApplicationModel.UserActivities.IUserActivityFactory), 393216, "Windows.Foundation.UniversalApiContract")]
public sealed class UserActivity
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 327680)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.ApplicationModel.UserActivities.IUserActivityFactory), 393216, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class UserActivity
function UserActivity(activityId)
Public NotInheritable Class UserActivity
Inheritance
Object Platform::Object IInspectable UserActivity
Attributes

Windows requirements

Device family
Windows 10 Fall Creators Update (introduced in 10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v5.0)

Remarks

Note

Starting in July 2021, users who have activity history synced across their Windows devices through their Microsoft Account (MSA) will no longer have the option to upload new activity in Timeline. They'll still be able to use Timeline and see their activity history (information about recent apps, websites and files) on their local PC. AAD-connected accounts won't be impacted.

A UserActivity encapsulates a user's task that can be continued at a later time, and potentially on a different device. Creating a User Activity causes that activity to be capable of appearing in Windows Timeline and in Cortana's Pick up where I left off feature. Timeline is a rich task view that shows a chronological view of what you’ve been working on, via activities that Windows believes to have had significant user engagement. It can also include what you were working on across devices. For example, a mail app could create a UserActivity when the user starts creating a new email message. The user could pause working on the email and then work on it later on the same machine, or even another device.

Version history

Windows version SDK version Value added
1803 17134 UserActivity
1803 17134 ToJson
1803 17134 ToJsonArray
1803 17134 TryParseFromJson
1803 17134 TryParseFromJsonArray
1809 17763 IsRoamable

Constructors

UserActivity(String)

Create a UserActivity with a specified activity ID

Properties

ActivationUri

Gets and sets the activation Uniform Resource Identifier (URI).

ActivityId

Gets the activity ID that was assigned to this UserActivity when it was created.

ContentInfo

Gets or sets the content information object for this user activity.

ContentType

Gets and sets the MIME (Multipurpose Internet Mail Extensions) type of the content stored at UserActivity.ContentUri. For example, "text/plain".

ContentUri

Gets and sets the content Uniform Resource Identifier (URI) of the content or document that is represented by the UserActivity.

FallbackUri

Gets and sets the fallback Uniform Resource Identifier (URI) to use if there is no handler for the activation URI.

IsRoamable

Gets and sets whether the particular activity's metadata should be uploaded to the Microsoft Cloud.

State

Gets the state (Published or New) of this UserActivity.

VisualElements

Gets information that can be used for the details tile for this activity.

Methods

CreateSession()

Creates a UserActivitySession that this user activity will be associated with. You must call this method on the UI thread.

SaveAsync()

Publish the UserActivity.

ToJson()

Serializes the UserActivity into a JSON string. Among other things, the JSON string will contain the App display name, the activation URL, the content URL, content information, and visual element information such as description, background color, and so on.

ToJsonArray(IIterable<UserActivity>)

Serializes a collection of UserActivity objects into a JSON string. Among other things, the JSON string will contain the App display name, the activation URL, the content URL, content information, and visual element information such as description, background color, and so on for each UserActivity.

TryParseFromJson(String)

Constructs a UserActivity from a JSON string.

TryParseFromJsonArray(String)

Creates a collection of UserActivity objects from a JSON string.

Applies to

See also