0 Replies Latest reply: Oct 19, 2013 9:59 AM by turbidity RSS

    How to Tell When AIR on Android Exits?

    turbidity Community Member

      Hi all,

       

      I'm trying to listen for the Event.EXITING event dispatched by the NativeApplication class in an Android app built with AIR. The event never seems to get dispatched. I notice that autoExit on NativeApplication is only supported for OSes that support NativeWindow. When I trace NativeWindow.isSupported, I get false.

       

      So if NativeWindow is not supported, is there anyway to tell if an app is being exited and not just losing focus? I just need to save some local data if the app is being closed.

       

      I'm on Android 4.3 on a Galaxy Nexus. Here's the code in my POC:

       

      private function _onApplicationComplete( event:FlexEvent ):void

      {

          trace( '### start' );

          trace( 'is native window supported ' + NativeWindow.isSupported );

          NativeApplication.nativeApplication.autoExit = true;

          NativeApplication.nativeApplication.addEventListener( Event.EXITING, _onExit );

      }

       

      private function _onExit( event:Event ):void

      {

          trace( '### exiting ' );

      }

       

      Thanks!