How to turn on speaker programmatically when incoming calls received and headphone attached on audio jack?
audiomanager.setSpeakerphoneOn(true)
Be sure to include the MODIFY_AUDIO_SETTINGS permission in your manifest.
// for android 10 and higher
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.putExtra(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, true);
callIntent.setData(Uri.parse("tel:" + phone));
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