Listening for Sleep state on Android

Is there a way for a Haxe Android app to listen for when the device goes to sleep? It appears that loseFocus() isn’t called until the after the app wakes up. I’d like to pause the game when the device goes to sleep as we are seeing errors on certain devices when sleep happens. Thanks.


stage.addEventListener(Event.ACTIVATE, onActivate);
stage.addEventListener(Event.DEACTIVATE, onDeActivate);

Thanks, rainy. I will give that a try.