Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Bluetooth & WakeLock relationship

Tags:

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.

like image 332
Christopher Souvey Avatar asked Aug 10 '11 16:08

Christopher Souvey


People also ask

Do Android phones have Bluetooth?

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.

Why is my Bluetooth not connecting?

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.


1 Answers

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.

like image 143
Valentin Avatar answered Oct 05 '22 09:10

Valentin