Check if UWP-Application is in Foreground/Focused [duplicate]

二次信任 提交于 2019-12-07 10:40:54

问题


I want to check if the current application is in the foreground/focused. The application is a windows-10 UWP application.

What i already got is, to check if the current application is minimized. For that i use the VisibilityChanged event of Window.Current.

But i don´t find a solution, to detect if the application is in foreground or not.


回答1:


I can't be 100% sure but it seems that Windows.UI.Xaml.Window.Activated event should suit your needs.




回答2:


You app cannot know it is in background because it does not run when in background. You can only react to the app getting suspending. For more info, check out the App lifecycle documentation: https://msdn.microsoft.com/en-us/library/windows/apps/mt243287.aspx



来源:https://stackoverflow.com/questions/34857990/check-if-uwp-application-is-in-foreground-focused

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!