I want to add a function to my application (which usually performs most of its functions as a service) so that it can track when the device is picked up.
My plan (although I'm not sure if this is the best way) is to use an accelerometer to monitor the movement.
Reading the android docs, he says that you should unregister the sensor as soon as possible since it can drain the battery in a few hours.
So my question is, is there a way to use the sensor effectively so as not to drain the battery, but still detect the movements of the device when it rises?
Or is there a better way to do this.
I am currently registering a sensor as follows:
mSensorManager.registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
source
share