Posted By

sidneydekoning on 10/29/10


Tagged

AIR android exit


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

sexyflash
donaldleegraham
ovakimyan
carface
jondiscipulo


Exit you application AIR for ANDROID


 / Published in: ActionScript 3
 

For your Air for Android application to properly close you need to define some handlers and respond to them.

  1. // Check if we are on a Android / iPhoney device.
  2. if(Capabilities.cpuArchitecture=="ARM")
  3. {
  4. NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, handleActivate, false, 0, true);
  5. NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, handleDeactivate, false, 0, true);
  6. NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleKeys, false, 0, true);
  7. }
  8.  
  9. private function handleActivate(event:Event):void
  10. {
  11. NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
  12. }
  13.  
  14. private function handleDeactivate(event:Event):void
  15. {
  16. NativeApplication.nativeApplication.exit();
  17. }
  18.  
  19. private function handleKeys(event:KeyboardEvent):void
  20. {
  21. if(event.keyCode == Keyboard.BACK)
  22. NativeApplication.nativeApplication.exit();
  23. }

Report this snippet  

You need to login to post a comment.