1 Reply Latest reply on Oct 13, 2012 9:56 AM by madetofallblog

    View deactivate on screen orientation change (mobile app)

    u1vandyk

      Hi all

      Im writing an Android app in Flash Builder 4.6 and I noticed that when I run the application and press the BACK key in my root View, the app closes, BUT STILL STAYS IN MEMORY. I figured that when I handle the View's deactivate event (which got fired because I pressed the Back key) I can exit the nativeApplication (to be removed from memory) like this:

       

      <s:View  xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"

      deactivate="deactivateHandler(event)" skinClass="skins.HomeViewSkin" title="MyApp" overlayControls.portrait="false" tabBarVisible.portrait="false">

       

        <fx:Script>

      <![CDATA[

      protected function deactivateHandler(event:Event): void {

      NativeApplication.nativeApplication.exit();}

      ]]>

      </fx:Script>

       

      THIS CREATED ANOTHER PROBLEM FOR ME:

       

       

      Now everytime I change the orientation of my phone (WHICH ALSO FIRES THE VIEW'S DEACTIVATE EVENT), the app closes because of the event handle I created above.

      Is there any way I can prevent the app from closing when the phone orientation changes??

      Cheers

      Johan

      ...

        • 1. Re: View deactivate on screen orientation change (mobile app)
          madetofallblog

          I'm bumping this topic.

           

          I'm having this same issue, due to the nature of the app I cannot disable orientation changes but I don't feel good leaving the application running - I feel it's poor design.

          So, I really need to either be able to exclude the deactivate event from the resize event, or I need another way to force the app to exit when the user leaves the app.

           

          Does anyone have a potential fix for this?

           

          Thanks,

          --Austin