Pause and Resume Audio recording in Android

Sneha John picture Sneha John · Apr 21, 2011 · Viewed 7.2k times · Source

I am developing an audio recording application in Android 2.3 using MediaRecorder class. I have the following requirement :

  1. When an interruption occurs , say during recording a call , pause recording .
  2. After the interruption is over and onResume of my recording activity is called , I have to resume recording from the point where it was paused .

I could not find a MediaRecorder api to pause and resume recording. Only start() and stop() are available.
Apart from recording two separate files before and after interruption and then joining them together into one file, is there any other way to achieve this?

Sneha John.

Answer

Ravinder  picture Ravinder · Apr 9, 2012

There are two possible ways to do this task, if u are using media recorder for the recording than you can append one audio file into another, Like when you got a incoming call than automatically your on pause is called and on your onPause() you can recorde that 1st file, when you comes back again on your activity than you can record a temporary fileResume() and append this temporary file into the previous one.

And another way is using AudioRecorder() class. In that you can record audio as raw file and append those files as per your requirement and finally when you want to stop the recording than add a header into that raw file and convert that into your desired audio format.