I'm looking for a way to automatically connect Android device to a Bluetooth LE (4.0 Smart) device when it comes in range (and starts advertising). I expect it to work like a Bluetooth headphones - when turned on they automatically connect to a paired phone (if it is in range).
I thought about running a Service in background that will periodically (every 50-100ms) check for advertisement. However one of the main concerns is battery life of Android device.
Could someone please advice what would be the best way to implement such functionality on Android 4.3 and up ?
Thanks in advance!
A headset or a speaker doesn't reconnect automaticallyReturn to Settings, search for Bluetooth auto-connect and enable this feature. Make sure that the other device is within the effective Bluetooth range from your smartphone and restart it. Re-enable Bluetooth on the phone and check if the issue is fixed*.
You can use Bluetooth to connect some devices to your phone without a cord. After you pair a Bluetooth device for the first time, your devices can pair automatically.
This is also why turning off Bluetooth on either device will prevent the connection. You can't stop Android Auto from turning on Bluetooth because it's a necessary function of the system.
set autoConnect parameter in connectGatt() to true. (second parameter)
You can register a broadcast receiver to receive broadcasts when a Bluetooth device is found. See the API guide topic Bluetooth for details and sample code.
Also look at the topic Bluetooth Low Energy.
Finally, take a look at this thread, which is basically the same question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With