Gen*_*idd 3 c# windows windows-10 uwp windows-10-universal
我正在使用的UWP应用程序使用Launcher启动另一个我也写过的UWP应用程序.这是我用来启动其他应用程序的代码:
var uriToLaunch = "testapp-mainpage://";
var uri = new Uri(uriToLaunch);
bool success = await Windows.System.Launcher.LaunchUriAsync(uri);
Run Code Online (Sandbox Code Playgroud)
到目前为止,这段代码能够启动我编写的其他应用程序,但它只是打开应用程序窗口,默认的蓝色背景,中间有一个X,基本上是默认的UWP启动画面.我已经尝试将URI设置为定位应用程序的MainPage,但无论我如何尝试修改URI,它都会启动到默认的启动画面.我正在推出的应用程序目前只是一个非常基本的默认UWP应用程序.如果启动的应用程序没有完全初始化,我错过了什么或做错了什么?
您需要修改已启动的应用程序以处理协议激活.默认向导生成app.xaml.cs,它通过OnLaunched处理典型的激活,但不通过OnActivated处理备用激活:
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.Protocol)
{
ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;
// TODO: Handle URI activation
// The received URI is eventArgs.Uri.AbsoluteUri
// You'll likely want to navigate to a page based on AbsoluteUri
// If you just want to launch the main page you can call essentially
// the same code as OnLaunched
}
}
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅MSDN上的句柄URI激活.有关具体示例,请参阅Association Launching Sample.
| 归档时间: |
|
| 查看次数: |
807 次 |
| 最近记录: |