0

I have this line

manager.registerListener(sensorListener, manager.getDefaultSensor(Sensor.TYPE_PRESSURE), logTime);

where logTime = 300000000 microseconds = 5 minutes.

I am trying to log every 5 minutes but with this setup it logs every second or so. Do you know what could be wrong or how to solve this?

My manager is a SensorManager.

BR

7heViking
  • 7,137
  • 11
  • 50
  • 94
  • 2
    ``SensorManager.registerListener`` takes ``rate`` as a hint only. There's no guarantee value you provide is obeyed. – harism Jan 14 '13 at 13:26

1 Answers1

0

Better setup for your task would be scheduled alarm waking up your application every 5 minutes. Then you can register listener and deregister it ater one sample is received.

Konstantin Pribluda
  • 12,329
  • 1
  • 30
  • 35
  • that sounds interesting... but how do I do that? – 7heViking Jan 14 '13 at 15:17
  • You will need broadcast receiver ( read about this in tutorial ) and scheduled alarm (I would say with wakeup of device - if you like to have proper pressure chart). You may schedule alarm from your activity, or in case there is not one, from another broadcast receiver listening on BOOT_COMPLETE event ( this is safest option, because scheduled alarms do not alsways survive boot ) – Konstantin Pribluda Jan 14 '13 at 15:49