Sney
Sney

Reputation: 2506

Use android.app.Service and SensorEventListener while screen is off (Android 2.1)

Hi: I'm using Android 2.1 on a HTC Nexus One. I want to collect sensor data while the device is turned off. By using android.app.Service this works well while the app is in the background but stops working when the display is turned off by the hardware button.

Is there a possibility to collect sensor data while the display is turned off?

Upvotes: 0

Views: 920

Answers (3)

Sney
Sney

Reputation: 2506

@Dre: WakeLocks are alrerady activated.

The solution is by using Android 2.2 (Froyo). Even when the display is turned off, the device can log the sensors.

Upvotes: 0

Dre
Dre

Reputation: 4329

Unless you hold a partial or higher wake lock, turning off the display can allow the CPU to fall asleep.

See the android.os.PowerManager documentation for information on how to use wake locks.

Upvotes: 2

Skizit
Skizit

Reputation: 44872

I've never had to do this myself but try reading this it may be of some help. You could try setting up each situation and specify that services remain running. Although if other services suck up more resources your application will be more likely killed by the linux Kernel over time. As I said I've never had to do this myself, but I think that would work.

Upvotes: 0

Related Questions