4 Replies Latest reply on Aug 20, 2011 4:56 PM by Francisc

    Exit Mobile Application on Timer complete event

    Francisc Level 3

      Hello,

       

      Why is this not working on an Android device, but working on desktop?

       

      private function onDeactivate(event:Event):void
      {
          applicationExitTimer=new Timer(600000,1);//10 minutes
          applicationExitTimer.addEventListener(TimerEvent.TIMER_COMPLETE,exitApplication);
          applicationExitTimer.start();
      }
      public function exitApplication(event:Event=null):void
      {
          NativeApplication.nativeApplication.exit();
      }

        • 1. Re: Exit Mobile Application on Timer complete event
          kokorito Level 4

          I guess after 10 minutes android has put the app to sleep

           

          I have an app that logs on to a website every hour, but it doesnt work how I want it to

          if I use KEEP_AWAKE then it does, screen stays on and app in focus the timer fires and it conects. If the user presses the power button to turn the screen off then the app goes to sleep and the timer stops

          unless the phone is plugged in to the charger and the android developer menu is set to stay awake when debugging, then the screen can be switched off but the app continues to run

           

          apparently there are further updates coming to flex that will allow more OS commands

           

          and somwhere on these forums there is an unoffical hack that allows you to register the app as a service, might be helpful, I havent tried it

          • 2. Re: Exit Mobile Application on Timer complete event
            Francisc Level 3

            Hm... that's odd. I'm doing that so that the Flex App closes after 10 minutes of losing focus, trying to save battery.

            Otherwise it stays as an Active Application. Using KEEP_AWAKE to achieve just this seems paradoxal.

             

            The idea was that if someone presses the Menu button or gets a phone call the app doesn't close unless 10 minutes have passed since doing so.

             

            And if I'm not wrong, it's a recommanded practice by one of the Flex Evangelists.

            • 3. Re: Exit Mobile Application on Timer complete event
              kokorito Level 4

              /me shrugs

              if thats why you are doing it then I dont think you need to bother.

               

              to check if the app is still active you have to switch the phone on, which activates the app again

              I think for an app to truly run in the background even when the phone is asleep it has to be registered as a service

              1 person found this helpful
              • 4. Re: Exit Mobile Application on Timer complete event
                Francisc Level 3

                Yeah, well the thing is I don't want it to run in the background either. I hate apps that don't really close when I close them.

                 

                Here's where I read about this: http://www.terrenceryan.com/blog/post.cfm/delay-closing-mobile-apps-on-exit

                 

                Thank you for your help.