Android Bluetooth Connectivity: Lost and Found
Ever since my first release of BT/notify, people have asked me what’s the deal with the Override Bluetooth Detection button and why would they need it. So, today’s blog will show you what it does and why BT/notify 3.0 will be even easier to use than ever before.
Car Stereos are Just Like Gazelles
Do you remember middle school science class? The teacher said that predators see moving prey more easily? That’s why a lion can find a gazelle more easily while it’s running across the Serengeti.
It turns out that Android has no way for a developer to ask the phone which devices are connected. In other words, I can’t write an app that asks, “Hey Phone, is a Bluetooth stereo connected?”
Instead, you have to ask your phone to tell you when it sees a device connect or disconnect. In other words, your phone is the lion that can only hunt the gazelle (your car stereo) when it sees it moving.
For a developer, that means that your app needs to keep its own list of connected devices. When your phone sees a device connect, BT/notify adds that to its own list of devices. Likewise, when your phone sees a device disconnect, BT/notify removes it from its own list.
Let’s Confuse the Lion Some More
Now that your phone has seen a device connect or disconnect, we still don’t know what kind of device connected. That device could be a car, a smartwatch, or a robot. To continue with the lion metaphor, remember that the lion needs to know if it sees food or not. Is the moving object it sees is a scrumptious gazelle or just the shadow of a bird flying by.
Similarly, BT/notify has to study the device that connected or disconnected. By looking at the devices properties, it figures out whether it should play the incoming message sound. If it guesses wrong, you might hear a sound at an inopportune time or you might not receive a message while driving. Over the three years I’ve been developing the app, I’ve gotten pretty good at figuring out when audio is appropriate. Nonetheless, every now and then my code guesses incorrectly. You can work around these wrong guesses with the Override Bluetooth Detection button.
Lion Vs. Anti-Lion: Mutually Assured Embarrassment
If BT/notify guessed incorrectly as to whether or not it connected to a car stereo, that would mean missing messages as you drive. Furthermore, you also might hear the alert sound when you’re not driving. I created the Override Bluetooth Detection feature to overcome this issue. Whenever you enable that feature, the phone does exactly the opposite of what it had guessed.
So, if BT/notify thought your phone connected to a stereo, it would not relay the message. If BT/notify thought you didn’t connect to a stereo, it would relay the message. This non-ideal approach helped you get the messages you should. Usually, the first time you disconnect and reconnect from your car, BT/notify starts guessing correctly and you can disable Override Bluetooth Detection.
Those features change completely in BT/notify 3.0.
Now Our Lion Won the Lottery

It occurred to me that most audio apps send song titles to your speakers no matter what. If your phone connects to a car or home stereo that displays song track information, the title of your song gets displayed. If you connect to something like a headset that has no screen, your phone still sends the track information, but you just don’t see it since the headset has no screen. How about if we use that bit of knowledge to get BT/notify working immediately before your first disconnect/reconnect from the car?
When you first install BT/notify or the first time you use it after you reboot your phone, it temporarily mutes its alert sounds. Right after install, your car stereo should start showing messages on the car stereo screen. It just won’t play an alert sound when it does. After that first disconnect/reconnect, we lift the temporary mute, and the notification you choose will play at the volume you choose.
Google is Smarter than a Lion or Gazelle
If you’ve made it this far, you probably do have some interest in Android Bluetooth connectivity. A great place to start is the Android Developer Bluetooth overview. Once you know the basics, the trick to keeping track of connections is to keep an array of BluetoothDevice objects. Just add or remove items from the array when you receive connect and disconnect events.
On the other hand, if you arrived at this blog post before you saw the main site, I invite you to learn more about BT/notify.