Reputation: 75
I want to share content from Edge browser into my app (when my app is in minimized state). But, it is not working. LaunchUriAsync is not restoring app window. Possible reason, app is running in background task, that is why UI operation is not working?
Can anyone suggest any solution?
Upvotes: 1
Views: 82
Reputation: 32775
How to Share from edge browser to UWP app when app is in minimized state c# uwp
In general, you could open the UWP app that registered to become the default handler for a Uniform Resource Identifier (URI) scheme name. Then we could add the app's launch uri into html page for browser like the following.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>App36</title>
<link href="css/default.css" rel="stylesheet" />
</head>
<body>
<div>Content goes here!</div>
<div>
<a href="ms-windows-store:">OpenApp</a>
</div>
<script src="js/main.js"></script>
</body>
</html>
When you click OpenApp label in browser that runs in the Window 10 operation system, it will launch the store app. You could replace ms-windows-store: with your app Uri protocol name(eg:myapp:)to launch your app and pass parameter base on your design.
In UWP client we need process the shared parameter from browser in OnActivated
method and invoke Window.Current.Activate()
finally.
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);
}
Window.Current.Activate();
}
For more detail please Handle URI activation.
Upvotes: 1