您可以使用以下代码切换蓝牙耳机麦克风 .
AudioManager audiomanager= (AudioManager)(Context
.AUDIO_SERVICE);
IntentFilter intentFilter = new IntentFilter(AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED);
(mBluetoothScoReceiver, intentFilter);
();
并听取广播接收器 .
private BroadcastReceiver mBluetoothScoReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
int state = (AudioManager.EXTRA_SCO_AUDIO_STATE, -1);
if (state == AudioManager.SCO_AUDIO_STATE_CONNECTED) {
// Start recording audio
log("audio connected");
startRecording();
} else if(state == AudioManager.SCO_AUDIO_STATE_DISCONNECTED){
log("audio disconnected");
}
}
};
并且要切换(断开蓝牙耳机麦克风),您可以使用此代码 .
();