简体   繁体   中英

Record a call through MIC on Samsung devices (Android 7.0)

I've simple Android app that record a call and it works fine on Android 6 + Samsung devices (both with MIC source and VOICE_COMMUNICATION). But once Samsung devices updated to Nougat (for ex. S7 / S7 Edge) these methods to record a call failed :( MIC record only my voice but not opponent voice and VOICE_COMMUNICATION does not works at all.

Could anybody advice what can be done here?

same problem. still looking for the answer.

I've got a samsung s7. Firstly, I'v unlocked native recorder (in dialer) and it's works. So, android 7 (and samsung) can record calls without inner actions inside of Android. But, in the same time I've read that developers can't get the access to recording calls from higher level. It seems like there's only one way to achieve our goals: modification of stock Android's version or catch sound stream before it gets to speaker. Fix me if I wrong.

Normally for recording phone call, we can use 4 types: DEFAULT, MIC, VOICE_CALL, VOICE_COMMUNICATION. But with 3 types below is enough for all

MIC, VOICE_CALL, VOICE_COMMUNICATION

base on the android version of your phone that will support or don't support some of them.

So to make your app work perfectly with all android versions we should change the AudioSource type following the android version with this rule:

if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
    recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
    callType = "VOICE_CALL";
} else if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
    recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    callType = "MIC";
} else {
    recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION);
    callType = "VOICE_COMMUNICATION";
}

I am using this on my application and it worked on most devices. It's no need to add any C library. Check my example application to see how they react with a dedicated Android version.

Github: https://github.com/tntkhang/call-recording-master

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM