Search

 

October 2010
S M T W T F S
« Sep   Nov »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Tags

Archives


« | Main | »

Exiting an AIR on Android Application

By Rich Tretola | October 13, 2010
25,936 views

I was reading this post this morning “Tip: Close Your Android AIR App on Back Button“. I decided to add it to my AIRonAndroid Browser app (which I use for testing functionality). I ran into an issue on my first run through when I went into the CameraRoll and CameraUI test screens. The problem is that if you use the sample code as is shown below (taken from Tip: Close Your Android AIR App on Back Button), the application will close when you use these classes. The reason is that CameraUI and CameraRoll use the devises native functionality. So, once you call the CameraUI launch() or CameraRoll browseForImage() methods, you are not going to get back to the application because it will have closed when you left it.

1
2
3
4
5
6
if(Capabilities.cpuArchitecture=="ARM")
{
    NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, handleActivate, false, 0, true);
    NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, handleDeactivate, false, 0, true);
    NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleKeys, false, 0, true);
}

So, how do you deal with this? The workaround is simple. Just be sure to remove the NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, handleDeactivate, false, 0, true); event listener before calling the CameraUI launch() or CameraRoll browseForImage() methods and then adding it back when the Camera MediaEvent.COMPLETE or CameraRoll MediaEvent.SELECT events are fired.

Topics: Adobe AIR, android, Flex | 4 Comments »

4 Responses to “Exiting an AIR on Android Application”

  1. Andrew Westberg Says:
    October 13th, 2010 at 3:55 pm

    Is there something wrong with the AIR runtime that everyone wants to close their apps when the back button is pushed? The recommended design for the Android life cycle is to leave them running. Why is everyone deviating from the standard life cycle?

    http://www.youtube.com/watch?v=fL6gSd4ugSI

    Reply to this comment

  2. anonguy Says:
    January 24th, 2011 at 1:54 am

    The expected behavior is for apps to exit when you back out if them…

    Reply to this comment

  3. SavageLook.com » The Good, The Bad, and The Ugly of Flex “Hero” Says:
    February 8th, 2011 at 11:50 am

    [...] button. Seems easy enough, but it takes 3 event handlers to do it properly and even this method is not without its problems. Check out the code I used below, thanks to Tom Krcha: protected function [...]

  4. Amit Says:
    September 5th, 2011 at 8:26 am

    Is there any way we can remove the default pushView() transition. as per my requirment i need to show a login page while while changing the tab. What i am doing is pushing the login view on selected tab’s wiew navigator object which shows the default transition. i need to show the login view directly without animating.

    Please help.

    Reply to this comment

Comments