退出ANDROID应用程序AIR

【退出ANDROID应用程序AIR】赋料扬雄敌,诗看子建亲。这篇文章主要讲述退出ANDROID应用程序AIR相关的知识,希望能为你提供帮助。
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. }


    推荐阅读