I have a background service which need much power, but is only needed if the device ist moving. I registered a sensor
sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETE开发者_StackOverflow社区R), SensorManager.SENSOR_DELAY_GAME);
and wanted to sleep the thread if there is no motion detected, but the
onSensorChanged
event permanently raisend because of gravitation. I am able to calculate, if there is a real movement, but i want the service to use as less power as possible and don't want to calculate permanently the movement, is there a possibility to register a Listener which only raises the onSensorChanged event, if there is a real motion?
精彩评论