I am trying to create an application that reads data from a digital compass. I tried to reuse the code from Professional Development for Android, but a note was noted in the IDE
SensorListener type is deprecated
I think this is because the code from the book was written for an earlier version of the SDK, so I tried using SensorEventListener instead.
Then when I tried to register the listener
sensorManager.registerListener(sensorListener, SensorManager.SENSOR_ORIENTATION, SensorManager.SENSOR_DELAY_FASTEST);
there was an error:
The registerListener (SensorListener, int, int) method in the SensorManager type is not applicable for arguments (SensorEventListener, int, int)
so I tried to apply SensorEventListener to SensorListener, but the application is not working.
Does anyone know how to use the sensor in newer versions of the SDK?
Thanks.
source share