Windows键[UWP]退出后返回应用程序的事件[Win10 Mobile] [英] Event on returning to app, after exiting by Windows key [UWP][Win10 Mobile]

查看:127
本文介绍了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...
    }

这篇关于Windows键[UWP]退出后返回应用程序的事件[Win10 Mobile]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆