Search code examples
androidmedia-playerbroadcastreceiver

How to handle a call in android media player?


Possible Duplicate:
Android 2.1+ Pause for incoming/outgoing call, resume when done

I have created a mediaplayer in android and everything works fine except that the player keeps on playing when i receive a call. To handle a call i think we should use broadcast receiver and listen to phone state. But being a beginner i couldnt figure out how to implement it?.Please help

thanks


Solution

  • You'll want to set up PhoneStateListener, specifically paying attention to "onCallStateChanged method, and send commands to the media player as appropriate based on call state (pause when ringing, resume after hangup if so desired, etc).