将 uwp 应用程序置于前台

bring uwp app in foreground

我找到 关于如何检测应用程序是否在前台运行的信息。是否可以通过某种方式将我的 UWP 应用程序带到前台(当它在后台运行时)?也许可以通过后台任务实现?

这就是我在 Windows 10:

上为 UWP 运行 工作的方式
  1. 在您的清单中创建协议声明(插入对您的应用有意义的名称和显示名称)

    如此处解释:https://marcominerva.wordpress.com/2012/12/10/make-an-app-respond-to-url-requests-using-protocol-declaration/

Start creating a new Windows Store app. For our purpose, a Blank App is enough. Now, we need to open the Package.appxmanifest file, go to Declarations tab and add Protocol from the Available Declarations list. Then, we specify the URI schema we want to handle in the Name property:

  1. 在协议的应用程序设置中,将所需视图更改为 使用一半

  2. 只要您的应用程序应该出现在前台,请使用启动器调用您注册的协议

在下面的示例中,将 yourprotocolhere 替换为您为应用注册的协议。

await Windows.System.Launcher.LaunchUriAsync(new Uri("yourprotocolhere://"));