简体   繁体   中英

How to turn on speaker programmatically in android

收到来电并且耳机连接在音频插孔上时,如何以编程方式打开扬声器?

audiomanager.setSpeakerphoneOn(true)

请务必在清单中包含MODIFY_AUDIO_SETTINGS权限。

// 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));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM