Hi,

Am using the following code to record a conversation.

************************

public class CallRecordingProcess extends BroadcastReceiver {

    static AudioManager audiomanager;

    @Override
    public void onReceive(Context arg0, Intent arg1) {

        // If Call Recording is not enabled, return the control flow.
        if (!CallRecordingPrefs.isRecordingEnablesd) {
            Toast.makeText(arg0, CallRecordingPrefs.isRecordingEnablesd +
"",
                    Toast.LENGTH_SHORT).show();
            Log.d("DEBUG", "CallRecordingEnabled: true");
            return;
        }
        Log.d("DEBUG", "CallRecordingEnabled: true");

        MyPhoneStateListener phoneListeneer = new MyPhoneStateListener();
        TelephonyManager telephony = (TelephonyManager) arg0
                .getSystemService(Context.TELEPHONY_SERVICE);
        telephony.listen(phoneListeneer,
PhoneStateListener.LISTEN_CALL_STATE);
        audiomanager = (AudioManager) arg0
                .getSystemService(Context.AUDIO_SERVICE);
    }
}

class MyPhoneStateListener extends PhoneStateListener {

    final MediaRecorder recorder = new MediaRecorder();
    String PATH = "/mnt/sdcard/aaa.3gp";
    Boolean isRecording = false;
    static int count;

    public void onCallStateChanged(int state, String incomingNumber) {
        switch (state) {
        case TelephonyManager.CALL_STATE_IDLE:
            Log.d("DEBUG", "IDLE");

            count++;
            Log.d("DEBUG", "Count: " + count);

            if (isRecording) {
                Log.d("DEBUG", "Recording Successfull!!");
                recorder.stop();
                recorder.reset();
                recorder.release();
                CallRecordingProcess.audiomanager.setSpeakerphoneOn(false);
                isRecording = false;
            }
            break;
        case TelephonyManager.CALL_STATE_OFFHOOK:
            Log.d("DEBUG", "OFFHOOK");
            break;
        case TelephonyManager.CALL_STATE_RINGING:
            Log.d("DEBUG", "RINGING");
            CallRecordingProcess.audiomanager.setSpeakerphoneOn(true);
            Log.d("DEBUG", "Speakers: ON");
            isRecording = true;
            recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
            Log.d("DEBUG", "RINGING 1");
            recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
            Log.d("DEBUG", "RINGING 2");
            recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
            Log.d("DEBUG", "RINGING 3");
            recorder.setOutputFile(PATH);
            Log.d("DEBUG", "RINGING 4");
            try {
                Log.d("DEBUG", "RINGING 5");
                recorder.prepare();
            } catch (IllegalStateException e) {
                Log.d("DEBUG", "RINGING 6");
                Log.i("Start Recording", "prepare failed  1");
                e.printStackTrace();
            } catch (IOException e) {
                Log.d("DEBUG", "RINGING 7");
                Log.i("Start Recording", "prepare failed  2");
                e.printStackTrace();
            }
            Log.d("DEBUG", "RINGING 8");
            recorder.start();
            Log.d("DEBUG", "Recording Started...");
            break;
        }
    }

*********************


The code is working fine for the first incoming call. The conversation is
getting recorded successfully.
For the later calls, the conversation is not getting recorded.

Any help is appreciable.



-- 



Regards,
Bikkanati Prabhakar.
E-Mail: [email protected]
Blog:    http://LetsXploreIT.blogspot.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to