Bluetooth Hands Free Profile audio routing on Android

706 Views Asked by At

I am in a preliminary stage of writing a small, personal utility app and I have read quite a lot of about Bluetooth and Android Developer information about Bluetooth. I am just trying to understand what I want to implement is possible or not.

I would like to route audio and mic from my android phone to my car's Head Unit so I can use the car's mic and speakers. If I have a radio channel (FM-source) playing in my car and then I start a phone-call either from my phone or from the Head Unit, the audio from the radio will be muted and audio(and the mic I guess) will be routed through the speakers of my car. When I hang up, the radio starts playing again. This is the expected behavior I guess. If I put Bluetooth as a source on the car's Head Unit, then I can stream music from the phone over the car's speakers. In this way, I can also use Google Now/Assistant. Everything works fine and probably as expected.

Now what I really want to achieve from my app is that while the radio is playing (FM as source on the Head Unit), is to be able to use Google Now and with voice-input ask something and mic/audio should be routed through the car. This will not work if the Head Unit has FM-radio as a source. So my idea was that by using an app, I will somehow trigger the Head Unit to switch the source from FM-radio to Bluetooth-mode so I can use the mic/speakers of the car and then launch Google Now for voice input. When finished, the Head Unit should reset the audio source to FM-radio. Of course, I have no way to access the Head Unit programatically through APIs and change audio-source but maybe this can be done through Bluetooth (I assume phone calls and the switch of source on the Head Unit is done directly by the BT-protocol)

So I am wondering if this is possible using Android's AudioManager object. If yes, then I will study it further, if not, that be it. Either way, I will learn something new.

0

There are 0 best solutions below