tags:

views:

31

answers:

1

(sensorManager is a SensorManager) I'm trying to implement an orientation listener for my program. I declare the listener as a SensorEventListener. The API says I need to pass registerListener a SensorEventListener, Sensor, rate, and handler. What is the handler for?

Also, when I mouse over the error, it insists I use the deprecated veresion of the method for a SensorListener instead of a SensorEventListener. And this deprecated version doesn't require a handler. Anyone know why?

A: 

There is a non-depricated method that dies not require a handler. See docs.

public boolean  registerListener  (SensorEventListener listener, Sensor sensor, int rate);

The difference between the depricated and non-depricated methods is that the depricated methods us an int for the sensor, while the non-depricated ones take a Sensor object.

Mayra