gpt4 book ai didi

android - OnePlus 5 无法通过 audiomanager 在通话模式下启动扬声器

转载 作者:行者123 更新时间:2023-11-29 02:38:30 25 4
gpt4 key购买 nike

我尝试在通话模式下将设备音频设置为扬声器。
它适用于我检查过的大多数设备。

我购买了 OnePlus5 设备,但它无法在上面运行。

final AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audioManager.stopBluetoothSco();
audioManager.setBluetoothScoOn(false);
audioManager.setSpeakerphoneOn(true);

当我检查结果为假时:

audioManager.isSpeakerphoneOn() // return false

正如我在 logcat 中看到的那样,当我从 native 拨号器设置扬声器时,他们使用一些不同的对象来设置扬声器:

08-14 09:53:39.778 1562-2928/? I/Telecom: CallAudioRouteStateMachine: Message received: USER_SWITCH_SPEAKER=1104, arg1=0: ICA.sAR->CARSM.pM_USER_SWITCH_SPEAKER@COs_0
08-14 09:53:39.778 836-14835/? D/AudioPolicyManagerCustom: getOutputForDevice() returns output 13 flag 2
08-14 09:53:39.778 1562-2928/? I/Telecom: Event: Call TC@22: AUDIO_ROUTE, Leaving state ActiveEarpieceRoute: ICA.sAR->CARSM.pM_USER_SWITCH_SPEAKER@COs_0
08-14 09:53:39.778 1562-2928/? I/Telecom: Event: Call TC@22: AUDIO_ROUTE, Entering state ActiveSpeakerRoute: ICA.sAR->CARSM.pM_USER_SWITCH_SPEAKER@COs_0
08-14 09:53:39.778 836-1095/? D/APM_AudioPolicyManager: startOutput() output 13, stream 1, session 25
08-14 09:53:39.778 1562-2928/? I/Telecom: CallAudioRouteStateMachine: turning speaker phone true: ICA.sAR->CARSM.pM_USER_SWITCH_SPEAKER@COs_0
08-14 09:53:39.778 836-1095/? D/AudioPolicyManagerCustom: getNewOutputDevice() selected device 1
08-14 09:53:39.778 836-1095/? D/APM_AudioPolicyManager: setOutputDevice() device 0001 delayMs 0
08-14 09:53:39.779 836-1095/? D/APM_AudioPolicyManager: startOutput()--
08-14 09:53:39.779 1562-2928/? V/AudioManager: Elem: dalvik.system.VMStack.getThreadStackTrace(Native Method)
08-14 09:53:39.779 1562-2928/? V/AudioManager: Elem: java.lang.Thread.getStackTrace(Thread.java:1566)
08-14 09:53:39.779 1562-2928/? V/AudioManager: Elem: android.media.AudioManager.setSpeakerphoneOn(AudioManager.java:1286)
08-14 09:53:39.779 1562-2928/? V/AudioManager: Elem: com.android.server.telecom.CallAudioRouteStateMachine.setSpeakerphoneOn(CallAudioRouteStateMachine.java:1353)
08-14 09:53:39.779 1562-2795/? D/VibratorService: timeout: 0, startTime: 6699313, pattern: [0, 10], vibrateIntensity: Middle, repeat: -1, usageHint: 13, uid: 1001, opPkg: com.android.incallui

[ 08-14 09:53:39.780 1562: 8387 E/ ]
Vibrator on : 10

最佳答案

添加<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

关于android - OnePlus 5 无法通过 audiomanager 在通话模式下启动扬声器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45672121/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com