Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn on speaker programmatically in android

Tags:

android

How to turn on speaker programmatically when incoming calls received and headphone attached on audio jack?

like image 226
ARDaniyal Avatar asked Nov 20 '25 17:11

ARDaniyal


2 Answers

audiomanager.setSpeakerphoneOn(true)

Be sure to include the MODIFY_AUDIO_SETTINGS permission in your manifest.

like image 140
Yusuf X Avatar answered Nov 23 '25 06:11

Yusuf X


// 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));
like image 32
Elad D Avatar answered Nov 23 '25 08:11

Elad D



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!