6

I'm trying to use the android.net.rtp library to make a VoIP application. Its audio stream can be both sent and received correctly.

My problem is: The speaker of the callee's phone works fine, but the headset is muted at all time (even if I turn off the speaker).

My code:

AudioManager Audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); 
Audio.setMode(AudioManager.MODE_IN_COMMUNICATION);
Audio.setSpeakerphoneOn(true);
Audio.setMicrophoneMute(false);
sender = new RtpStreamSender(null, "169.0.199.19", AudioCodec.PCMU);
aboger
  • 2,214
  • 6
  • 33
  • 47
jane
  • 81
  • 3

1 Answers1

0

This code help you.

@SuppressWarnings("deprecation")
        boolean isWiredHeadsetOn = audioManager.isWiredHeadsetOn();
        audioManager.setMode(isWiredHeadsetOn ?
            AudioManager.MODE_IN_CALL : AudioManager.MODE_IN_COMMUNICATION);
        audioManager.setSpeakerphoneOn(false);