【发布时间】:2018-12-28 23:04:44
【问题描述】:
我使用 LaunchUriAsync 启动了一个 uwp 应用程序,但应用程序没有正确加载(不显示应用程序的主页),它显示默认蓝屏
public MainPage()
{
this.InitializeComponent();
callUri();
}
private async void callUri()
{
var uriBing = new Uri((@"testapptolaunch://"));
// Launch the URI
var success = await Windows.System.Launcher.LaunchUriAsync(uriBing);
}
并在 app.xaml.cs 添加以下代码
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.Protocol)
{
ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;
// Navigate to a view
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
{
rootFrame = new Frame();
Window.Current.Content = rootFrame;
}
// assuming you wanna go to MainPage when activated via protocol
rootFrame.Navigate(typeof(MainPage), eventArgs);
}
}
【问题讨论】:
-
嗨@Sruthi A,如果这个或任何答案解决了您的问题,请点击复选标记考虑accepting it。这向更广泛的社区表明您找到了解决方案,并为回答者和您自己赢得了一些声誉。
标签: uwp