Search code examples
androidalarmmanageralarmandroid-alarmswakelock

Efficiency of regular wakeups (Alarms) vs. staying awake (WakeLocks)


I want to accept Bluetooth connections (even when the screen is off) for building a mobile ad-hoc P2P network. Since it seems that incoming connections don't wake the device up, I think I will either need to keep the device permanently awake with a partial WakeLock (which will drain the battery relatively quickly), or wake it up for short periods of time to check for new connections.

Now, my question is: Is it more efficient to wake the device up at regular intervals, or is it better to just keep it awake because the wakeup-sleep-transition will eat more power than simply keeping the device awake all the time? The intervals I am talking about here are on a scale of 1-10 seconds.

Alternate solutions that get around the issue are also highly welcome, of course, if they aren't limited to a small set of devices.


Solution

  • You need to test with a real device and you might get different results with different devices. Generally, if you are going to wake up every second, just keep the thing awake (you can blank the screen to save some power). Or you can use something like cloud messaging (GCM) to wake up the device, but that will require a separate server. Example: device1 sends to server 'I am here message', server sends to device2 'device1 is over there, wake up and check it out' message, device1 connects to device2. This, of course, might be overkill for you :)