I have notice that when I press the power button of my android device, It dispatches the Event.DEACTIVATE, but after some time (about 1 second) it fires the Event.ACTIVATE on the same click.
So I pause my audio, but it plays again on ACTIVATE, even with my screen turned off.
I just do trace on my functions and when i press the button off I get traced:
“ON PAUSE”
“ON RESUME”
my code:
#if android
Lib.current.stage.addEventListener(Event.DEACTIVATE, _onPause);
Lib.current.stage.addEventListener(Event.ACTIVATE, _onResume);
#end
private function _onPause(e:Event):Void
{
trace(“ON PAUSE”);
}
private function _onResume(e:Event):Void
{
trace(“ON RESUME”);
}