Sensors Tutorial for Android: Getting Started |

In this sensors tutorial, you’ll learn about different types of sensors and how to use sensor fusion (accelerometer with magnetometer) to develop a compass.

This is a companion discussion topic for the original entry at

sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD)?.also { magneticField →
sensorManager.registerListener(this, magneticField, SensorManager.SENSOR_DELAY_NORMAL, SensorManager.SENSOR_DELAY_UI)

this is not working sensorManager.registerListener(param 1 should be listener in the example we have (this) in this scope this is a service not a listener. I think that is the problem let me know