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
Asked
Active
Viewed 332 times
0
-
Your app is also a UWP app? Did you try setting the view size in LauncherOptions? – Anders Jan 03 '22 at 15:21
-
Documentation says "By setting DesiredRemainingView, you aren't guaranteed a specific windowing behavior for the source app." So this is not a guaranteed to give me the required result right? – rsp Jan 03 '22 at 19:59
1 Answers
1
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.

Nico Zhu
- 32,367
- 2
- 15
- 36
-
This OnActivated need to be implemented in the target app that I am launching right? That is not my app. – rsp Jan 04 '22 at 05:11
-
Also, if not using protocol url, is there any other way to launch app with its main window in background? – rsp Jan 04 '22 at 05:14
-
Yep, the `OnActivated` need to be implanted in the target app, for uwp there is no other way to launcher app in background. And if you want connection without launch the app, you could try to implement it with appservice, but the appservice also need to be implanted in the target app. – Nico Zhu Jan 04 '22 at 05:48
-
If you do want to such feature please feel free post your requirement with windows feed back hub, and if the answer is helpful or solve the problem, please consider mark it. – Nico Zhu Jan 04 '22 at 08:48