Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - how do sensor readings affect battery life

i have added a feature in my app that uses the proximity and accelerometer sensors (the second is to detect shakes). This is implemented in an always running service (if the user selects it of course). But I fear for the battery usage that my ap will have. I have NOT used any wake locks but i still get readings even when screen is off as i can see in my logs. The question is: what of the following is true?

  1. The two mentioned sensors are activated anyway by android system the whole time (in which case me collecting the readings as well does not affect battery life...i guess).
  2. Android system turns these sensors off most of the time (in which case me keeping them always on through my service affects battery life)

If (2) is true: Is it possible to implement my own sleep cycle for the sensors or will the whole toggle process make things worse?

like image 648
Anonymous Avatar asked Jan 26 '14 11:01

Anonymous


People also ask

Does sensors off save battery?

This will give you a new "Sensors Off" quick toggle to enable or disable all the Sensors on the phone, including the camera and mic. I've found this saves quite a bit of battery while not affecting most everyday uses. Additionally, overnight, my S22 only used about 3% of battery in 6 hours of idle time.

What does turning sensors off on Android do?

Sensor behavior When Sensors off is enabled, the sensors stop reporting any data to the system or apps. An app can still request a sensor and register a listener when Sensors off is enabled, but either silence is returned for the mic or the onSensorChanged callback is never invoked for the sensors.

What do sensors do on Android?

Android sensors are virtual devices that provide data coming from a set of physical sensors: accelerometers, gyroscopes, magnetometers, barometer, humidity, pressure, light, proximity and heart rate sensors.

What tasks in an application consumes more battery?

Your app should minimize its activity when in the background and when the device is running on battery power. Sensors, such as GPS sensors, can drain battery significantly.


1 Answers

Amount of power taken by sensor varies from sensor to sensor, and device to device.

On average, your most power hungry sensors are the GPS, accelerometer and gyroscope. Leaving them On all the time will reduce the battery faster.So you should pause the sensor when the device is where-ever not necessary.

After that, the light sensor and compass are much less battery intensive, but if you use them for long enough even they'll affect battery life.

besides this you can test your app for sometime how much it takes, or you can use getPower () to return the power in mA used by this sensor while in use.

There is no exact method for this actually.If your app have to use the sensor then use it when its needed.

thanks

like image 96
unitedartinc Avatar answered Oct 20 '22 18:10

unitedartinc