Search code examples
androidandroid-mediaplayertelephonymanager

Handling Incoming calls in android application


I have developed a music related android application. I have a problem in handling the mediaplayer on incoming call. I want to pause the audio during the phonecall and resume it back after the call gets ended. I need suggestions whether to use TelephonyManager with onstatechanged to pause and resume the audio (OR ) any other methods to pause and resume the application itself during Incoming calls.


Solution

  • use onPause() and onResume() methods in your activity. When an incoming call comes, onPause() method is called. and onResume() is called when call is hung up.

    This will work even if the user clicks on a notification sent from some other app.