I'm working on an Android application that runs in the background and enables support for a Bluetooth accessory. I would like to be constantly listening in the background for the Bluetooth device to try and open a socket to the phone. My question is whether it is possible to achieve this without constantly keeping a partial wakelock, since that would obviously have severe battery consequences. So what I'm wondering is what effect Bluetooth has on the phone falling asleep. Does the phone stay awake when there is an open Bluetooth socket? Does the Bluetooth chip wake up Android automatically if a device tries to connect? I've attempted to do some testing to answer these questions, but it's difficult to isolate what is happening with wake locks; in addition, I don't know if I can rely on the behavior I observe or if it subject to change on other devices.
You can connect Bluetooth devices faster if you're using the Quick Settings menu to turn Bluetooth on. Tap (or tap and hold) the Bluetooth icon, and Android immediately starts to scan for Bluetooth available devices.
For Android phones, go to Settings > System > Advanced> Reset Options > Reset Wi-fi, mobile & Bluetooth. For iOS and iPadOS device, you'll have to unpair all of your devices (go to Setting > Bluetooth, select the info icon and choose Forget This Device for each device) then restart your phone or tablet.
Yes, if your application is running and a thread is in serverSocket.accept() method, incoming connection wake up phone, so there is no need to use wakelocks. However, make sure that your service is in foreground and is not killed by system.
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