0

i am a newb in android and i am working in an application which starts when a phonecall is recieved in the device, and starts a IntenService to record the call Using media recorder.here is my log cat output.

01-14 13:58:07.319: D/DEBUG(18180): <!>com.agicent.callrecorder.CallListener 26<!> 
OFFHOOK
01-14 13:58:07.319: E/AudioRecordTest(18180): 
<!>com.agicent.callrecorder.PhoneCallRecorderActivity 181<!> Recording Started
01-14 13:58:07.469: E/AudioRecordTest(18180): 
<!>com.agicent.callrecorder.PhoneCallRecorderActivity 181<!> Recording Started
01-14 13:58:07.499: E/MediaRecorder(18180): start failed: -1
01-14 13:58:07.509: W/dalvikvm(18180): threadid=9: thread exiting with uncaught 
exception (group=0x40018560)
01-14 13:58:07.509: E/AndroidRuntime(18180): FATAL EXCEPTION: 
IntentService[PhoneCallRecorderActivity]
01-14 13:58:07.509: E/AndroidRuntime(18180): java.lang.RuntimeException: start failed.
01-14 13:58:07.509: E/AndroidRuntime(18180):    at 
android.media.MediaRecorder.start(Native Method)
01-14 13:58:07.509: E/AndroidRuntime(18180):    atcom.agicent.callrecorder.PhoneCallRecorderActivity.startRecording(PhoneCallRecorderActivity.java:77)
01-14 13:58:07.509: E/AndroidRuntime(18180):    at com.agicent.callrecorder.PhoneCallRecorderActivity.onHandleIntent(PhoneCallRecorderActivity.java:182)
01-14 13:58:07.509: E/AndroidRuntime(18180):    at    android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:59)
01-14 13:58:07.509: E/AndroidRuntime(18180):    at android.os.Handler.dispatchMessage(Handler.java:99)
01-14 13:58:07.509: E/AndroidRuntime(18180):    at android.os.Looper.loop(Looper.java:123)
01-14 13:58:07.509: E/AndroidRuntime(18180):    at  android.os.HandlerThread.run(HandlerThread.java:60)
01-14 13:58:20.539: E/IncomingCall Recieved(18256):       <!>com.agicent.callrecorder.IncomingCallReciever 33<!> Broadcast Recieved
01-14 13:58:20.569: D/DEBUG(18256): <!>com.agicent.callrecorder.CallListener 22<!> IDLE

And here i my code block

public class PhoneCallRecorderActivity extends IntentService {

private static final String LOG_TAG = "AudioRecordTest";
private static String mFileName = null;
//private RecordButton mRecordButton = null;
private MediaRecorder mRecorder = null;
//private PlayButton   mPlayButton = null;
private MediaPlayer   mPlayer = null;

private void startPlaying() {
    mPlayer = new MediaPlayer();
    try {
        mPlayer.setDataSource(mFileName);
        mPlayer.prepare();
        mPlayer.start();
    } catch (IOException e) {
        Log.e(LOG_TAG, "prepare() failed");
    }
}

private void stopPlaying() {
    mPlayer.release();
    mPlayer = null;
}

private void startRecording() {
    mRecorder = new MediaRecorder();
    mRecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
    mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    mRecorder.setOutputFile(mFileName);
    mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);


    try {
        mRecorder.prepare();
    } catch (IOException e) {
        Log.e(LOG_TAG, "prepare() failed");
    }

    mRecorder.start();
}

private void stopRecording() {
    mRecorder.stop();
    mRecorder.release();
    mRecorder = null;
}

public PhoneCallRecorderActivity() {
    super("PhoneCallRecorderActivity");
    mFileName = Environment.getExternalStorageDirectory().getAbsolutePath();
    mFileName += "/audiorecordtest.3gp";
}
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}

@Override
protected void onHandleIntent(Intent intent) {
// TODO Auto-generated method stub
Log.e(LOG_TAG, "Recording Started");
startRecording();
}
public void onDestroy() {

stopRecording();
Log.e(LOG_TAG, "Recording finidhed");

}
}

please suggest me where i am doing wrong. Thanks a lot for your time.

Muni Mishra
  • 409
  • 2
  • 5
  • 16

1 Answers1

0

If you are looking to record the actual call itself (local voice and remote voice), that is not possible in Android, as the call audio information is handled outside of Android itself.

Padma Kumar
  • 19,893
  • 17
  • 73
  • 130