Hi @DotNET Fan ,
It is recommended to register a protocol to launch your UWP app.
App,xaml.cs
protected override void OnActivated(IActivatedEventArgs args)
{
// Window management
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
{
rootFrame = new Frame();
Window.Current.Content = rootFrame;
}
rootFrame.Navigate(typeof(MainPage), args);
Window.Current.Activate();
}
MainPage.xaml.cs
private async void Button_Click(object sender, RoutedEventArgs e)
{
var uri = new Uri("test-app2app:");
var success = await Windows.System.Launcher.LaunchUriAsync(uri);
}
Package.appxmanifest
<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="UWPlaunchTest.App"
desktop4:SupportsMultipleInstances="true">
<Extensions>
<uap:Extension Category="windows.protocol">
<uap:Protocol Name="test-app2app" ReturnResults="always">
<uap:DisplayName>Test app-2-app</uap:DisplayName>
</uap:Protocol>
</uap:Extension>
</Extensions>
<uap:VisualElements
DisplayName="UWPlaunchTest"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png"
Description="UWPlaunchTest"
BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.