简体   繁体   中英

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

I want to launch UWP app from another app. For example I want to launch apps with launch protocol (ms-people:, msnweather:, etc.). I am using 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). However I want to keep this new app window in the background and let user interact with the original app. How do I do that? Thanks

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

I'm afraid LaunchUriAsync api does not contain such options to launch app's main window in background using url. But we have a workaround that push the launched app into background manually if the app was launched with uri.

The OnActivated event handler receives all activation events. The Kind property indicates the type of activation event. 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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