I am using phonegap with Android.I have a sound playing repeatedly with a timer.If I close the app the sound continues to play.Is there a app closing handler or something I could use to make the sound stop when the app exits.
I am using a Samsung Captivate(Galaxy S).If I press the back button the sound stops when the app exits.But if I press the home button then the sound just goes on forever when the app exits.
Thanks
You can catch the backbutton and stop the music playing and then close the app.
It's however not possible (as far as i know) to catch the close event.
http://wiki.phonegap.com/w/page/29494136/Android-Back-Button-Handler
Here is how to do that.
Related
I am making a music player app. I made a custom notification with player buttons. While other things are just working fine, I am unable to find on how can I quit application when user presses quit button on the notification.
I tried system.exit() and musicService.stopSelf() but of no use from here.
In Android development, is it possible to keep a VideoView playing after sending the user to HOME screen, so, when the user opens the Application once again, the video is already running?
Like, when I leave the activity, the video stops playing and when I go back to the same Activity, the video restarts. Is there some way to keep it running, like in the background?
Thank you!
In your onPause() of the activity you can pause the video get the current seekLevel by getCurrentPosition() and in your on resume if the video was playting you can pick up where you left of
I have developed a music player application,which has a service(AudioPlayerService) which will be running in the background.Service will be started when play button is pressed. It will run in the background even though application goes to background.
Playback can be stopped by bringing the app to foreground and press the stop button, which makes the music to stop and stops the AudioPlayerService too. everything works fine.
Otherway i can use the Force Stop from Settings app (Settions->Application->Downloaded->Select the App->Press Force Stop Button).
I am able to stop the application and music also stopped playing.
But If i use Stop button from Settings App (Settings->Applications->Running->Select the App -> Press Stop), application is terminated and my app is removed from the running app list, but music is still playing in the background.
I am not sure why Running Tab Stop Button does not stop the music.
Any one help me if i need to handle anything in my service to class to stop the playback.
I am testing in Samsung Galaxy S2 with Android 4.0.3
Thanks
Sasikumar JP
On the onDestroy override method of your service use your mediaplayer object to stop the media from playing.
#Override
OnDestroy{
mediaplyer.stop();
}
I am trying to make an application that stops the music player when the button is pressed?
everything works fine but i am not able to close the music player application? any suggestion or help....
I have seen this post here (http://stackoverflow.com/questions/151777/how-do-i-save-an-android-applications-state). I am having a similar problem I believe.
I have an app which listens to an audio stream (using the mediaPlayer object). If I press the Home button it will continue streaming and hide my app. Then, at a later point I can go back to my app and press stop when I'm done. This is what I want. If however I press the Back button, when I later open my app again the app has been redrawn from fresh. Text boxes, buttons, everything has reset like I've just opened the app for the first time so I can't stop my audio stream. Clicking stop does nothing because the app has 'forgotten' it is streaming (the stream runs under a separate handler from the main UI thread, so I'm guessing since its been 'reset' it has lost track of its handlers?).
Why does this happen with the Back button, and how can I stop it?
Move the streaming functionality into an Android Service. Use an Activity to bind to the Service and to interact with it.