问题
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