Windows键[UWP]退出后返回应用程序的事件[Win10 Mobile]

问题描述:

我很难为我找到合适的事件-在我的应用程序[UWP Windows 10 Mobile app]中浏览文件时,用户可以点击它,然后通过以下方式在默认应用程序中启动它

I have big trouble finding right event for me - user during browsing files in my app [UWP Windows 10 Mobile app] can tap on it and then I launch it in default app by

Windows.System.Launcher.LaunchFileAsync

我的应用程序已最小化"(就像按Windows键一样),用户可以在他想要的任何应用程序中与文件进行交互.现在,通过按返回键,他将返回到我的应用程序.您知道现在发生了什么事吗?我想更新文件(如果已更改),但是找不到任何事件来检查它.

my app is 'minimzed' (just like by pressing Windows key) and user can interact with file in whatever app he wants. Now by pressing back-key he is returning to my app. Do you know any event which is trigerred now? I want to update the file (if it was changed) but I cannot find any event to check it.

了解UWP应用的生命周期很重要. 如果您想控制应用程序在首次启动,挂起"或恢复"时发生的情况,请参考以下指南:

It is important to understand the UWP app lifecycle. If you want to have control on what is happening while application is Launched first time, Suspended or Resumed you should refer to below guideline:

https://msdn.microsoft.com/zh-cn/windows/uwp/launch-resume/app-lifecycle

还可以在App.xaml.cs文件中管理此循环.例如,您可以控制从后台恢复应用程序时的操作:

Also in the App.xaml.cs file you can manage this cycle. For instance you can control what to do when application is Resumed from the background:

    public App()
    {
        this.InitializeComponent();
        this.Suspending += OnSuspending;
        this.Resuming += App_Resuming;
    }

    private void App_Resuming(object sender, object e)
    {
       //Code to execute while resuming the app...
    }