3

I can't find a list of events that can be listened for while a device is sleeping.

For example, it is possible to use LocationListener while asleep.

My goal is to detect when a user is in his car by at least one of the following methods, which will then wake the phone:

  • NFC tag on car dock
  • Bluetooth-enabled car radio in range

But failing those, I'm open to ideas.

Thanks

Community
  • 1
  • 1
Jodes
  • 14,118
  • 26
  • 97
  • 156

2 Answers2

0

You should create a brodcast receiver and register specific actions.

An example to detect a boot: Android -Starting Service at Boot Time.

Community
  • 1
  • 1
  • Thanks - I already use a broadcast receiver for NFC tags and Bluetooth devices, they work while the device is awake but not while asleep. – Jodes Aug 25 '14 at 10:02
0

The best idea so far is to wake the phone periodically as per this link:

Android - periodically wake up from standby mode?

As per the documentation, I could wake the phone up and just use the CPU, while keeping the screen off.

But there might be disadvantages, perhaps there is a better way.

Community
  • 1
  • 1
Jodes
  • 14,118
  • 26
  • 97
  • 156
  • *argh* Please avoid this if possible. It's what causes the battery to drain rapidly if not used responsibly by the apps (- which often think they're so important that I really want them to run every few seconds or so :-E). – JimmyB Aug 25 '14 at 11:21
  • I agree.. it's a pretty nasty way of doing it – Jodes Aug 25 '14 at 13:42