Audiomanager扬声器不起作用 [英] Audiomanager Speaker not working

查看:243
本文介绍了Audiomanager扬声器不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在通话中启用扬声器:

I'm trying to enable the speaker while I am in a call:

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

我试图在setSpeakerphoneOn()之后检查音频管理器,并通过询问isSpeakerphoneOn()

I tried to check after the setSpeakerphoneOn() the audiomanager and get that the speaker is still not on by asking isSpeakerphoneOn()

audioManager.isSpeakerphoneOn();

在我的日志中,我看到一些我不理解的错误:

In my log I can see some errors that I can't understand:

E/AudioManager: Don't setBluetoothScoOn-PackageName: com.myapp.app  on = false
E/AudioManager: Don't setSpeakerphoneOn-PackageName: com.myapp.app  on = true

我在论坛中找不到有关此错误的任何信息.

I can't find anything about this error in the forum.

无法在设备上运行:中兴Z981,华为p9,我已经尝试过 ,并授予android.permission.MODIFY_AUDIO_SETTINGS.

Didn't work on devices: ZTE Z981, Huawei p9, I already tried this, and android.permission.MODIFY_AUDIO_SETTINGS is granted.

推荐答案

我发现setSpeakerphoneOn()之前的setMode()(当前模式)修复了logcat上的错误:

I found that setMode() (the current mode) before setSpeakerphoneOn() fixes the error on the logcat:

AudioManager audioManager = (AudioManager)getApplicationContext().getSystemService(Context.AUDIO_SERVICE); 
audioManager.setMode(AudioManager.MODE_IN_CALL);
audioManager.setSpeakerphoneOn(true);

这篇关于Audiomanager扬声器不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆