This question has been asked and answered twice before on this site, but that code doesn't seem to work on modern phones at all. I'm working on an Android 4.2 and an Android 4.3 and neither seems to work.
I am playing an MP3 through a Media Player during the call, and it works fine, but both the song and the call are coming through the voice speaker. If I press "Speaker" they both continue playing through the loudspeaker. I need that effect, but without having to press it myself
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audioManager.setMode(AudioManager.MODE_IN_CALL);
audioManager.setSpeakerphoneOn(true);
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
This was suggested as a solution to both other questions on S.O, but it simply doesn't work. It should, the code is fine, but it simply does nothing to the audio at all.
Thoughts?
Helpful answers. If when on a call you can only see the number dialer screen, Tap the "Hide" text at the bottom right corner of the screen to return to the phone options. Then Tap the Speaker icon to turn on the Speakerphone.
If your Android loudspeaker won't work, restart the device and check for updates. Additionally, reset the sound settings, and disable Bluetooth and Do Not Disturb mode. If the issue persists, remove the case, clean your speaker grills, enter Safe Mode, and reset your settings.
Head into Settings > Connected devices to see if your phone is connected to any Bluetooth audio outputs. After this, you should head into the Sound section of Settings and confirm you haven't accidentally switched on the Do Not Disturb or Silent modes.
I solved it. I created a thread that constantly runs the above three lines of code in a "While (true)". Works great.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With