Android Question Accelerometer Battery Drain while Phone Sleeps

PhilipK

Member
Licensed User
Longtime User
Hi

I'm finishing an app with a service module that successfully logs the accelerometer data, to record 3 axis movement when the phone is near vertical. I want to gather the horizontal accelerations of the phone while it is near vertical as part of a measurement system.

If the phone has been asleep, say flat on a table, for some time, on picking it up, without touching/unlocking the screen, the logging often takes time to start again. Perhaps a minute or more. I guess the CPU is being woken up and having to catch up with other tasks.

I have now implemented the PhoneWakeState.PartialLock to keep the CPU running. This works very well and the new data logging is instantaneous engaged when the phone is angled vertical.

One very undesirable outcome: Unfortunately, while the phone is back on the table, doing nothing, the battery is taking a wasteful beating because the CPU and accelerometers are running fulltime and being read non-stop. Any ideas on how to reduce the drain?

Somewhere here, I read that you could use sensors.initilaze2 to advise the CPU to scan the accelerometers slower and therefore reduce battery drain. But will this setting deny my higher speed data logging?


Thanks
 

PhilipK

Member
Licensed User
Longtime User
Thanks again Erel.

I have implemented Initialize2.

I see that a partial lock is effective but interferes with the normal operation of the CPU and phone. So I'm thinking of doing something different.

Will stop listening to the sensor as well.

BTW, just had a brief go with your new B4J cross platform IDE. Wow, what a great tool!
 
Upvote 0
Top