共用方式為


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 ,否則此方法將會失敗。

適用於