次の方法で共有


UserActivity.State プロパティ

定義

この UserActivity の状態 (発行済みまたは新規) を取得します。

public:
 property UserActivityState State { UserActivityState get(); };
UserActivityState State();
public UserActivityState State { get; }
var userActivityState = userActivity.state;
Public ReadOnly Property State As UserActivityState

プロパティ値

この UserActivity の状態。

UserActivity userActivity = await channel.GetOrCreateUserActivityAsync(activityId);

//if it's a new UserActivity associate metadata with it
if (userActivity.State == UserActivityState.New)
{
    //required fields, SaveAsync() throws ArgumentNullException if not set
    userActivity.ActivationUri = new Uri("rss-reader:article?" + article.Link);
    userActivity.DisplayText = article.Title; //used for details tile text

    //optional fields
    userActivity.FallbackUri = article.Link;

    //we don't have a website for the app, but the article can be viewed in a browser
    userActivity.ContentUri = article.Link;

    userActivity.VisualElements.Description = article.Summary; //optional

    userActivity.ContentInfo = UserActivityContentInfo.FromJson(
        @"{
        ""@context"": ""http://schema.org"",
        ""@type"": ""Article"",
        ""author"": ""John Doe"",
        ""name"": ""How to Tie a Reef Knot""
        }");
    await userActivity.SaveAsync();
}

注釈

UserActivity[新規] と [発行済み] であることを確認すると、GetOrCreateUserActivityAsync() が新しく作成された UserActivity または以前に作成された UserActivity を返したかどうかを判断できます。

適用対象