UserActivityRequest.SetUserActivity(UserActivity) 方法

定义

设置在引发 UserActivityRequested 事件时返回的 UserActivity。

public:
 virtual void SetUserActivity(UserActivity ^ activity) = SetUserActivity;
void SetUserActivity(UserActivity const& activity);
public void SetUserActivity(UserActivity activity);
function setUserActivity(activity)
Public Sub SetUserActivity (activity As UserActivity)

参数

activity
UserActivity

要存储的用户活动。

示例

private async void UserActivityRequested(
    Windows.ApplicationModel.UserActivities.UserActivityRequestManager sender,
    Windows.ApplicationModel.UserActivities.UserActivityRequestedEventArgs args)
{
    UserActivity userActivity = // app code to create a userActivity
    args.Request.SetUserActivity(userActivity);
}

注解

必须设置 UserActivity.ActivationUriUserActivity.VisualElements.DisplayText,否则此方法将失败。

适用于