I do not think there is a general solution to this problem. The reason is that
1) the quality of the headphones can be poor, there may be an internal connection between the microphone and the headphones, since the wires are very close in the headphones.
2) Echo canceller in android is optional for all devices. Try to request it and settings first. also the implementation of the echo canceller may vary from device to device
3) latency greatly affects the performance of the echo canceller, as the algorithm must adapt to the delay and buffer a lot of audio.
4) lower versions of android have terrible latency problems, confirmed by Google itself. You might want to upgrade to a higher version of Android, as it has improved a lot.
In general, any API that has some direct access to hardware, such as a microphone and camera, can vary from device to device, and performance cannot be guaranteed.
you can look at openSLES for better sound performance and easier integration into the AEC library if you want to integrate.
Take a look - https://source.android.com/devices/latency_design.html Play low-latency audio on Android https://www.youtube.com/watch?v=d3kfEeMZ65c
Hope this helps,
Regards, Shrish
source share