Record file when other side person receive my call?
<p>When phone state goes to OFFHOOK mode recording starts automatically, but there is problem: recording starts even though call has not been received - that means when phone is dialing, at the same time recording starts.</p>

<p>I want the recording to start when the other side of person receives the call. How should I do that?</p>

<p>This is my code</p>

<pre><code>final TelephonyManager telephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        telephony.listen(new PhoneStateListener() {
            public void onCallStateChanged(final int state,
                    final String incomingNumber) {
                try {
                    switch (state) {
                    case TelephonyManager.CALL_STATE_IDLE:
                        if (Recorder != null) {
                            Recorder.release();
                            Recorder.stop();
                        }
                        Log.d("TestActivity", "Call is idle.");
                        actionStop(getApplicationContext());
                        break;
                    case TelephonyManager.CALL_STATE_OFFHOOK:
                        Log.d("TestActivity", "Call connected");
                        startRecording();
                        break;
                    case TelephonyManager.CALL_STATE_RINGING:
                        break;
                    default:
                        break;
                    }
                } finally {

                }
            }
        }, PhoneStateListener.LISTEN_CALL_STATE);
    }
</code></pre>
