Reputation: 1
my problem is when device Mediaplayer is playing any song my Mediaplayer is not stopping.Both Mediaplayer playing song together.
Upvotes: 0
Views: 46
Reputation: 1973
When your application needs to output audio such as music or a notification, you should always request audio focus. Once it has focus, it can use the sound output freely, but it should always listen for focus changes.
Use AudioManager to request Audio Focus and implement AudioManager.OnAudioFocusChangeListener to respond to Audio Focus changes.
So listen to audiofocus changes and modify you app accordingly. See the hyperlink for more information.
Upvotes: 1