简体   繁体   English

如何使用 url 在后台使用应用程序的主 window 启动 UWP 应用程序

[英]How to launch UWP app with app's main window in background using url

I want to launch UWP app from another app.我想从另一个应用程序启动 UWP 应用程序。 For example I want to launch apps with launch protocol (ms-people:, msnweather:, etc.).例如,我想使用启动协议(ms-people:、msnweather: 等)启动应用程序。 I am using API LaunchUriAsync.我正在使用 API LaunchUriAsync。 It is launching the app.它正在启动应用程序。 But the new app that is launched gets the focus and its main window comes in the foreground on top of the app that I am interacting with (from which I launched this new app).但是推出的新应用程序得到了关注,它的主要 window 位于我正在与之交互的应用程序之上(我从中启动了这个新应用程序)。 However I want to keep this new app window in the background and let user interact with the original app.但是我想在后台保留这个新应用 window 并让用户与原始应用交互。 How do I do that?我怎么做? Thanks谢谢

How to launch UWP app with app's main window in background using url如何使用 url 在后台使用应用程序的主 window 启动 UWP 应用程序

I'm afraid LaunchUriAsync api does not contain such options to launch app's main window in background using url.恐怕LaunchUriAsync api 不包含使用 url 在后台启动应用程序主 window 的选项。 But we have a workaround that push the launched app into background manually if the app was launched with uri.但是,如果应用程序是使用 uri 启动的,我们有一个解决方法可以手动将启动的应用程序推送到后台。

The OnActivated event handler receives all activation events. OnActivated事件处理程序接收所有激活事件。 The Kind property indicates the type of activation event. Kind 属性指示激活事件的类型。 So you could minimize the target app in the following所以你可以在下面最小化目标应用程序

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
      }
   }

For minimize the app please refer this case reply .如需最小化应用程序,请参阅此案例回复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM