bring uwp app in foreground

后端 未结 1 1823
南方客
南方客 2021-01-14 06:10

I found posts about how to detect if the app runs in foreground. Is it possible to bring my UWP app to the foreground (when it runs in the background) somehow? Maybe it\'s p

相关标签:
1条回答
  • 2021-01-14 06:41

    This is how I got it to work for UWP running on Windows 10:

    1. In your manifest create a protocol declaration (insert Name and Display name meaningful to your app)

      As explained here: 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. In App settings for the protocol change the Desired view to Use Half

    2. Use the Launcher to call your registered protocol whenever your app should come to the foreground

    In the example below replace yourprotocolhere with the protocol you registered for your app.

    await Windows.System.Launcher.LaunchUriAsync(new Uri("yourprotocolhere://"));
    
    0 讨论(0)
提交回复
热议问题