When the screen is off, the processor goes into sleep mode and you cannot record events without doing a partial wakelock. I suggest you take a partial wakelock when you call onPause and release it onResume . Be careful with wakelocks, they make your phone consume really large amounts of energy, you must carefully monitor them.
PS: You have to purchase wakelock in the onPause method, because if you try to call it elsewhere, you may not be able to get it, because the CPU may already be closed.
Vittorio Cozzolino Jul 01 '13 at 10:22 2013-07-01 10:22
source share