On which Android Version?
Gesendet von Mail für Windows 10
Von: Eric Risdall
Gesendet: Montag, 4. Januar 2016 04:35
An: Android Developers
Betreff: [android-developers] How to stop an applications music/sound whenHOME
button is pressed?
I am developing an app in Flash Professional CS5.5 & Actionscript 3 for the
Android phone. When I hit the HOME button to exit the app, the background music
keeps playing. I have already tried the following two methods:
METHOD 1:
package
{ import flash.display.Sprite;
import flash.events.Event;
public class Main extends Sprite
{ public function Main():void
{ stage.addEventListener(Event.ACTIVATE, onAppActivated);
stage.addEventListener(Event.DEACTIVATE, onAppDeactivated);
}
private function onAppActivated(e:Event):void
{ // Play audio
}
private function onAppDeactivated(e:Event):void
{ // Stop audio
}
}
}
METHOD 2:
package
{ import flash.desktop.NativeApplication
import flash.events.KeyboardEvent;
public class Main extends Sprite
{ public function Main():void
{
NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN,
onKeyDown);
}
protected function onKeyDown(e:KeyboardEvent):void
{ if(e.keyCode == Keyboard.HOME)
{ //stop audio.
}
}
}
}
Neither method works for stopping the audio & frankly i'm at a loss as for how
to proceed here. Is there any way to override the home key? or maybe there is
something I can add to the XML manifest for the app? (something like
<key>UIApplicationExitsOnSuspend</key><true/>]]>?)
--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-developers/ebcfa486-b6c3-4bd2-a564-c097713bbac7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-developers/568a6edd.4f911c0a.3af9c.4508%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.