开发者

Fire onSensorChanged only if there is a motion

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜