is there any way to record an incoming call through android code?
If this feature doesn't exist, then how can some third party applications record calls?
is there any way to record an incoming call through android code?
If this feature doesn't exist, then how can some third party applications record calls?
The ability to record a call is hardware or firmware dependent. Most Android phones don't have their internal "wiring" of audio path set up such that voice call audio reaches the application processor at all.
The apps that enable you to record a call on the market either:
Work only on those specific phones where the above is not true (very few models)
Or use a hack where they ask you to use a speakerphone and record the call audio actually from the phone microphone catching what the phone speakers send out...
a) Acquire READ_PHONE_STATE & RECORD_AUDIO permissions
b) Register a phone state receiver
<receiver android:name="com.record.app.callrecorderapp.CallStateListener" >
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
c) Trigger recording upon incoming call
public class CallStateListener extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
if (TelephonyManager.EXTRA_STATE_RINGING.equals(state)) {
startRecording();
}
}
}
d) Do actual recording
void startRecording() {
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
recorder.setOutputFile(filePath);
recorder.start();
}
There's more bookkeeping to it but you'll figure it out.
Should work on ~ 50% of the devices out there including Galaxy S4 + S5