I'm writing a program that processes SensorEvents. It needs to keep running and keep processing events even when the user isn't directly working with their phone (i.e. when it's just sitting in their pocket). To make that work, I need to prevent the phone from turning off. On the other hand, I don't want to waste power unnecessarily, so I don't want to prevent the screen from turning off.
Looking at the documentation, it seems that a WakeLock of type PARTIAL_WAKE_LOCK should do exactly what I want. But it doesn't work: as soon as the screen turns off, my program stops running (or at least onSensorChanged() stops getting called). If I instead use a lock of type SCREEN_DIM_WAKE_LOCK, everything works as expected and my program keeps running. But then the screen stays on (although dimmed), which is far from ideal. I then thought maybe I could just turn off the screen myself by setting WindowManager.LayoutParams.screenBrightness to 0. But no... as soon as I do that, my program stops running. It appears that "set the screen brightness to 0" is actually interpreted as "turn off the phone!" Is there any way I can make the display turn off while still allowing my program to keep running? Peter -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

