I want to use my headset with hfp and stream TTS to the headset without using the a2dp profile.
1) I init audio manager:
audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audio.setMode(AudioManager.MODE_IN_CALL);
2) I pair the device using reflection:
Method m = device.getClass().getMethod("createBond", (Class[]) null);
Object invokeResult = m.invoke(device, (Object[]) null);
3) when I receive the intent BluetoothDevice.ACTION_BOND_STATE_CHANGED and the new state is BluetoothDevice.BOND_BONDED I bind to the headset using the IBluetoothHeadset android interface.
mContext.bindService(new Intent(IBluetoothHeadset.class.getName()), mConnection, Context.BIND_AUTO_CREATE)
4) in the onServiceConnected
implementation I invoke:
boolean connectResult = mService.connect(headset);
5) if connectResult
is true, I init audio:
audio.setBluetoothScoOn(on);
audio.startBluetoothSco();
But, when I call:
tts.speak(text, TextToSpeech.QUEUE_ADD, null);
the audio is not redirected to the headset.
Note: in this case audio.isBluetoothA2dpOn() returns false.
I successfully redirect the audio ONLY if I previously paired the device using android system. In that case audio.isBluetoothA2dpOn(
) returns true.
Is there any way to use TTS with HFP profile?
I already tried this solution but it didn't work for me
TTS output always going to A2DP
Thanks!