Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving power with location services by detecting user movement using sensors

I'm working on an app that tracks the user's whereabouts. In order to save battery, I want to implement an idle zone that makes the location manager pull less frequently (or even stop) on the GPS location. Once the user starts moving again (detected by either accelerometer and/or significant movement), the location service will pull on the default interval.

One approach is to define the idle zone as the minDistance parameter in LocationManager::requestLocationUpdates, but other users around here suggests that it does not have any impact on the battery drain, and the documentation states that it is difficult for the location manager to save battery using this criteria:

However it is more difficult for location providers to save power using the minDistance parameter, so minTime should be the primary tool to conserving battery life.

Google also suggests using the significant motion sensor for detecting when the user location changes:

At the high level, the significant motion detector is used to reduce the power consumption of location determination. When the localization algorithms detect that the device is static, they can switch to a low power mode, where they rely on significant motion to wake the device up when the user is changing location.

Does this mean the location manager uses the significant motion sensor if it is present by default, or do I need to activate or implement something to make the location service use it?

And what about the accelerometers? A large part of my question lies in whether using the accelerometer to detect when the user starts moving would save any power, as using the accelerometer would be another sensor that would require power and callback handling. Some accelerometer sensors are listed as low-powered by Google, while some are not (including the significant movement sensor).

Would it be possible to save any battery power by putting the GPS to sleep and then use sensors to detect user movement which would wake up the GPS again?

like image 522
Martin Avatar asked Jul 16 '15 13:07

Martin


People also ask

What are motion sensors on my phone?

Depending on the device, these software-based sensors can derive their data either from the accelerometer and magnetometer or from the gyroscope. Motion sensors are useful for monitoring device movement, such as tilt, shake, rotation, or swing.

What is accelerometer sensor Android?

The accelerometer is an in-built comment of a smartphone to measure its acceleration. It tracks the different motion like shaking, tilting, swinging, and rotating and accordingly change the orientation of your app.

What are sensors in Android?

What are Android sensors? 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 is Android gyroscope?

Gyroscope in a smartphone provides a GUI that enables a user to select menus etc by tilting the phone. One can deflect the phone slightly to go up and down the contact list. It enables a smartphone to trigger preset commands basis different motions. For instance, one can shake the phone to lock it.


1 Answers

The LocationManager::requestLocationUpdates uses the significant motion sensor by using the high level method setSmallestDisplacement() Example:

mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(20*1000);
mLocationRequest.setFastestInterval(10*1000);
mLocationRequest.setSmallestDisplacement(10F); //meters
like image 131
Amir Avatar answered Oct 20 '22 19:10

Amir