Note that there are some explanatory texts on larger screens.

plurals
  1. POAccelerometer stops delivering samples when the screen is off on Droid/Nexus One even with a WakeLock
    primarykey
    data
    text
    <p>I have some code that extends a service and records onSensorChanged(SensorEvent event) accelerometer sensor readings on Android. I would like to be able to record these sensor readings even when the device is off (I'm careful with battery life and it's made obvious when it's running). While the screen is on the logging works fine on a 2.0.1 Motorola Droid and a 2.1 Nexus One. </p> <p>However, when the phone goes to sleep (by pushing the power button) the screen turns off and the <code>onSensorChanged</code> events stop being delivered (verified by using a Log.e message every N times <code>onSensorChanged</code> gets called). </p> <p>The service acquires a wakeLock to ensure that it keeps running in the background; but, it doesn't seem to have any effect. I've tried all the various PowerManager. wake locks but none of them seem to matter.</p> <pre><code>_WakeLock = _PowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "My Tag"); _WakeLock.acquire(); </code></pre> <p>There have been conflicting reports about whether or not you can actually get data from the sensors while the screen is off... anyone have any experience with this on a more modern version of Android (Eclair) and hardware?</p> <p>This seems to indicate that it was working in Cupcake: <a href="http://groups.google.com/group/android-developers/msg/a616773b12c2d9e5" rel="noreferrer">http://groups.google.com/group/android-developers/msg/a616773b12c2d9e5</a></p> <p>PS: The exact same code works as intended in 1.5 on a G1. The logging continues when the screen turns off, when the application is in the background, etc.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload