Bluetooth Hands Free Profile audio routing on Android - android

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.

Related

Android Car Head unit: external microphone works for some apps, but not in calls or Google voice search

I installed a cheap chinese Android based car head unit in my 15 year old second hand car, with probably Android 8 or 9 (maybe even a fake version where the version shown is higher than is installed). For most things it works. Sound output is good, bluetooth works, Wifi works, Google apps like Maps, Chrome, Youtube all work.
I have an external mic attached to it. There is a sound recording app, which records the sound when I use this mic. I can replay the sounds, so far so good. So here's the thing: the phone app does not pick up this mic, and also no sound on the tiny mic that's built in. Same for Google Voice Search, it just doesn't pick up anything. When I call someone, they don't hear me speaking at all.
My question is: how do I go about debugging it? Is there some kind of app that I can use to diagnose, which will at least show device mapping, or show signals like in Windows?

Android auto - will sound play to car speakers if played from app

I have some sound that plays during a phone call on my app. Its hard to test this on the desktop head unit but i'd like to know on a real device if i simply plug the phone into the car will my audio automatically play to the car speakers ? I notice when i use the DHU that it already sets the phone on speaker so im assuming it routes to the cars speakers but i wanted to make sure.
So to be clear, imagine i have an app that plays music based on some trigger, if i plug the phone into the car and execute that trigger will the audio get routed to the speakers of the car without the app needing to do anything ?
I plugged my phone into my Pioneey NEX head unit and the only audio that came through the head unit was that of the applications that support Android Auto. Any additional sounds (e.g. notifications not associated to an Android Auto application) were played by the phone itself.
Hope this helps.
dave

Use a bluetooth headset as a extended microphone for a camcorder using android phone

I'm trying to film a video with a camcorder.
However, the camcorder isn't support bluetooth microphone.
Fortunately, I think I found a way to do it, but I can not find good app to do it.
My plan is, use phone as a bluetooth receiver, and connect the audio port of the phone to the camcorder via cable.
I need:
an app that make the bluetooth headset as a default microphone of the system.
an app that make the sound from the bluetooth mic able to flow to the audio port.
I know about an app called "megaphone" in Apple store that makes sound from the phone's mic flows through to the phone's audio port.
But I can not use the bluetooth headset for it.
Any suggestion please?
Sounds like a great App. Start by installing Android Studio (http://developer.android.com/tools/studio/index.html) and then its about research... Search around SO (or google) for any of the keywords that sound reasonable. Look at the related questions (on the right panel) for other questions that have been asked with similar key words (you'll find tons of info)
Start a project, and ask questions when you get stuck.

Play music via android speakers

I want to make an app that makes it possible to connect an iPod or mp3 player to my Android device and let the Android speakers function as external speakers.
The ideal situation would be to actually read from speaker output so I can connect a stereo mini jack cable.
Is it possible to read from the headset output with the Android SDK?
A second option would be to use a mono mini jack instead. I could maybe directly read from microphone and output as a music player. Although, having to use a mono mini jack would be a huge disadvantage, because most people don't own such a cable.
UPDATE
For my second option I found this link that would let me take a special adapter onto a stereo cable so the iPod output can go into the mic input. It's a TRRS adapter. This works, but still isn't the ideal solution to me. http://www.techlife.net/2012/12/add-an-audio-input-to-android.html
ANOTHER UPDATE
I did a test with only a mono cable, but it seems that the mic is not recognized, so I really need the TRRS adapter to make sure that the mic is on. I found some apps that can help me with measuring input volume. I think I can achieve my goal for myself with the adapter, but reading from headset output would be nicer and could actually result in building an app.
You need to understand some basic things...
Audio output lets you "take audio out of your device".
It's not audio input that would let you "insert audio signal into your device".
So the concept that you've presented cannot work, because this socket is not able to receive audio signal through normal stereo jack cable (and connector).
You could try to make it work with a device that supports the headphones/mic set (it's a different kind of 3.5 mm jack connector). It's so called TRRS (four-conductor). But to use it in your project you probably would need some cable/socket soldering and maybe even some sort of microporcessor to help processing the signals.

Android: clicking noise is heard on headphone while playing audio when phone moves

I have written an Android app that receives audio from WiFi and plays it. When the phone is still and not moving the audio quality is great. But when I move the phone specially when it is connected to a headphone I can hear clicking noise. I am wondering if this is something known that can be mitigated in the App? For example since Android knows if the headphone is connected or not, if the jack is not very stable and shaky it could create some interrupts and cause this clicking noise? By the way the phone that I am doing the testing on is HTC Inspire 4g.
For benefit of others:
It looks like after some investigation it is not the headphone jack, but the wifi link that changes. When I hold the phone in my hand and move it quickly it looks like the wifi link gets very weak for a short period of time and I loose the link for some time and that causes the clicking noise.

Categories

Resources