如何在Android中通过蓝牙流式传输来电音频

时间:2013-09-30 07:42:04

标签: android bluetooth android-bluetooth

我可以通过headset从我的android mobilebluetooth接收,挂断和拨号。

现在,一旦我收到耳机中的移动电话,我需要通过耳机与被叫人通话。我需要通过蓝牙将我的声音传输到Android手机。我正在搜索此代码。

抓了n个帖子但是得不到合适的答案,目前正在使用以下但是它不起作用...

AudioManager audioManager;

audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
audioManager.startBluetoothSco();
audioManager.setBluetoothScoOn(true);
audioManager.setSpeakerphoneOn(true);

我不确定在此之后需要编写哪些代码来实现我的要求

注意:我通过将mmOutStream.write("ATA\r".getBytes());此AT命令发送到我的Android手机来接收来电。

请更正并指导我执行音频流。

1 个答案:

答案 0 :(得分:2)

您应该将免提电话设置为false,否则您的输出将被重定向。这样就足够了:

audioManager.setSpeakerphoneOn(false);
audioManager.startBluetoothSco();
audioManager.setBluetoothScoOn(true);

此外,您可以选择将麦克风设置为非静音状态(以防以前的状态被静音):

mAudioManager.setMicrophoneMute(false);