I use AudioTrack to play the sound that I get through UDP sockets. I get a lot of noise with the sound, so I decided to use AudioManager. But AudioManager changes the sound routing outside the application. Below is the code I'm using.
m_amAudioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); m_amAudioManager.setMode(AudioManager.MODE_IN_CALL); m_amAudioManager.setSpeakerphoneOn(false);
The problem with this code is that when I close the application and start the music player, the sound comes from the front speaker, and not from the rear speaker, and I can not change it in any way. To solve this problem, I decided to add the following line when I close the application.
m_amAudioManager.setSpeakerphoneOn(true);
But with this line, the problem is that when I receive a call (regular call), by default the speaker turns on. I really need help with this, please.
Soh
source share