Flex Mobile Apps Exit/suspend for Apple and Android

Getting ready to deploy the flex mobile app for android. Did a quick google on how to have the app exit so it does not hang around and use up battery life. Found a straightforward way to exit the android app per Tips for Flex mobile apps at RIAgora.

For android, on creationComplete event have the associated method set an event listener for deactivation:

protected function creationCompleteHandler(event:FlexEvent):void
{
NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, onDeactivateApp);
}
 

This will daisy chain the request to the method onDeactivateApp which is called when the deactivate event is dispatched. In this method, just request that the native applicaiton exit.

protected function onDeactivateApp(event:Event):void
{
	NativeApplication.nativeApplication.exit();
}
 

This only works for android. For apple devices, I found this posting called, Exit vs Suspend your IOS Applicaiton, explaining how to suspend your app for apple devices. To exit, you have to set the key UIApplicationExitsOnSuspend tag value via the app-descriptor xml file.


      <iPhone>
        <InfoAdditions><![CDATA[
            <key>UIDeviceFamily</key>
            <array>
                <string>1</string>
                <string>2</string>
            </array>
            <key>UIApplicationExitsOnSuspend</key>
            <true/>
        ]]></InfoAdditions>
        <requestedDisplayResolution>high</requestedDisplayResolution>
</iPhone>
 
Advertisements

One Response to Flex Mobile Apps Exit/suspend for Apple and Android

  1. Manoj Kumar says:

    Tanks, It was useful 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: