How to detect the app enter into the background or become foreground on mobile device?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By alexzheng

It seems there is no that kinds of notifications or signals for these events.

:bust_in_silhouette: Reply From: alexzheng

Maybe
MainLoop.NOTIFICATION_WM_FOCUS_IN
MainLoop.NOTIFICATION_WM_FOCUS_OUT
are the right notifications to detect.