1

I'm interested to switch between different sensor orientation speeds over time to optimize the program ie.. battery life. The routine may be called very often. I'm looking for the right practice.

       sensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
       sensorManager.registerListener(sensorListener, SensorManager.SENSOR_ORIENTATION, SensorManager.SENSOR_DELAY_FASTEST);
       //... 1) unregister then register new speed OR
       //... 2) register new speed without registering
       sensorManager.unregisterListener(sensorListener);

Should I unregister the listener and then register with SensorManager.SENSOR_DELAY_NORMAL
OR
Should I not bother unregistering the listener?

thanks.

Johnson Tey
  • 209
  • 1
  • 2
  • 8
  • 1
    I'm not sure about your question, but as a side note you will find that you get better performance with `SENSOR_DELAY_GAME` than `SENSOR_DELAY_FASTEST` because FASTEST actually polls the device so often that it starves other system proceses. – CaseyB Mar 11 '10 at 19:24
  • This is a good point to know. I just want to switch to polling more often when it becomes necessary... and then back to not. I just dunno what is a good choice to go about this. – Johnson Tey Mar 11 '10 at 19:32
  • Have you tried unregistering and re-registering? or anything for that matter? If so it would be helpful to note this. – While-E Apr 15 '11 at 14:05

0 Answers0