3 Replies Latest reply: Apr 18, 2013 6:50 AM by babyned RSS

    App sound keeps playing on Android device after closing

    babyned Community Member

      I'm developing apps for Android using Flash CS6. Everything runs fine, but when I hit the Home Button to leave the app, the background music still plays.

       

      I've been Googling this for hours and every solution I find mentions Activities and Services and a class called MediaPlayer, but flash CS6 doesn't recognize any of these things in code. Is anyone else having this problem? Seems like a pretty major one.

        • 1. Re: App sound keeps playing on Android device after closing
          kglad MVP

          are you testing on an android device or emulator?

          • 2. Re: App sound keeps playing on Android device after closing
            babyned Community Member

            Via USB on an Android phone. I am currently trying this method that I've found - not working yet though...

             

            import flash.desktop.NativeApplication;

             

            import flash.desktop.SystemIdleMode;

             

            import flash.system.Capabilities;

             

            import flash.system.System;

             

               

                 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.KE Y_DOWN, handleKeys, false, 0, true);

             

                }

             

                function handleActivate(event:Event):void

             

                {

             

                NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;

             

                }

             

                function handleDeactivate(event:Event):void

             

                {

             

                NativeApplication.nativeApplication.exit();

             

                }

             

                function handleKeys(event:KeyboardEvent):void

             

                {

             

                if(event.keyCode == Keyboard.BACK) {

             

                NativeApplication.nativeApplication.exit();

             

                }

             

                }

            • 3. Re: App sound keeps playing on Android device after closing
              babyned Community Member

              Thanks kglad, having tried that above code, it works!!! Here's the source:

               

              http://forums.adobe.com/thread/915804