how to stop musicplayer application from my application - android

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....

Related

Voice command for android music player app

I am working on an android music player and I wanna have hand-free voice commands,i.e., don't need to press any button to start recording. the app should keep listening all the time. Is there a way ?
You could use the Houndify SDK for voice recognition. It can be triggered without a button press, and it has music domains for searching and controlling music playback.
http://www.soundhound.com/houndify

how to detect when Music is played using Native Music Player?

I am making an app in which I've made a Service which plays Music from URLs. The thing is that my music Service is playing music correctly BUT when user plays any song with Native music player then BOTH(Native Player and My Music Service) are playing music simultaneously. I want to stop My Music Service when user started playing music with native player.
Is there any Broadcast Intent which i can register to Detect the
music player is started?
Is it possible to detect Music player Started?
Any Other Solution?
Any suggestions would appreciated.
I'll suggest a different approach, that I believe it's the correct approach.
the issue on your approach is that you're suggesting to check for one specific app. And there're tons of different music players, plus radio players, plus video players, plus games... and all of those should stop your music in case they want to play something.
So how you do it?
It's all explained in the Android Developers website.
You have to register an OnAudioFocusChangeListener, so, whenever a different app request to have the audio focus, your app can stop the music.
Step 1: Detect if the user has opened native music app. For this , you need to know the package name of your native music app.
Then refer to my answer here: Android how to know an app has been started and range apps priority according the starting times
Using that , the list taskinfo will have the list of all running activities, and as explained there, the first element of the list will be the activity in the foreground.
STEP 2: Once you detect native music app being activated using STEP 1 (by polling for it in the background) , then stop your app's service.
NOTE: You should do this in a background (using asynctask) or another service.
NOTE 2: The limitation of this method is that you can't actually stop the music player when the user clicks play in the native music app, since this method will help you detect only if the native music app is opened or not.

Android Service - stop the service from settings App

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();
}

how to stop the native android service playing music

I am developing a media app.
If a user plays a song with the native android application for playing a song and then opens my application then i want to stop playing that song in background before user opens my application. At present both songs are being played at a time.
You do not "stop playing that song in background before user opens my application". You request the audio focus using AudioManager.
You can have your program run the isPlaying() routine check if something is playing and take action against the media player if needed.

Phonegap app closing problem

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.

Categories

Resources