AppListEntry.LaunchForUserAsync(User) AppListEntry.LaunchForUserAsync(User) AppListEntry.LaunchForUserAsync(User) AppListEntry.LaunchForUserAsync(User) AppListEntry.LaunchForUserAsync(User) Method

Definition

Launch the app associated with this AppListEntry within the context of a specified user.

public : IAsyncOperation<Platform::Boolean> LaunchForUserAsync(User user)
IAsyncOperation<bool> LaunchForUserAsync(User user) const;
public IAsyncOperation<bool> LaunchForUserAsync(User user)
Public Function LaunchForUserAsync(user As User) As IAsyncOperation(Of bool)
Windows.ApplicationModel.Core.AppListEntry.launchForUserAsync(user).done( /* Your success and error handlers */ );

Parameters

user
User User User

The user context that the app should be launched under.

Returns

Returns true if the launch succeeds; otherwise, false.

Additional features and requirements

Device family
Windows 10, version 1803 (introduced v10.0.17134.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v6)

Examples

public async void LaunchButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
    // The active User is retrieved from the initial activation args and validated against list of active users
    User user = this.GetAppActiveUser();
    PackageManager pm = new PackageManager();
    // The App Family Name is stored as part of the Product Display Page
    Package p = pm.FindPackage(this.GetFocusedAppFamilyName());
    IReadOnlyList<AppListEntry> entries = await p.GetAppListEntriesAsync();

    //This assumes the first app in the package should be launched, if there is one in the package
    if (entries.Count > 0)
    {
        await entries[0].LaunchForUserAsync(user);
    }
}

Remarks

This is a Multi-User-Aware (MUA) API and can only be used by apps that declare themselves to be MUA, and only on devices that support MUA apps (like Xbox). The app is launched in the same way as if the specified user clicked on the entry in the app list. The user is passed to the launched app via the event args. Passing null for user will result in an exception.

MUA apps launch with the a default user context. The user value, which is passed to the activated application via the event arguments, indicates who the app is activating on behalf of. A Single-User-Aware app will launch in the context of the user value that is passed into this API.

See also