title: Android Studio:Kotlin RegisterListener
body: <p>I am new to Android development and would like to learn how to get data from the Accelerometer.</p>
  <p>I am following the example from this location: <a href="https://developer.android.com/reference/android/hardware/SensorManager" rel="nofollow noreferrer">https://developer.android.com/reference/android/hardware/SensorManager</a></p>
  <p>When I build and run my application it quits with no warning or messages about errors. I looked through the event logs but did not see anything that looked like a problem, but I am new to android/Kotlin so I could be missing something.  When I run on my phone I get a message that the application has stopped on the emulator I get not messages.</p>
  <p>The application fails sometime after the onResume event registers the listener and before the onSensorChanged event is called.  I added try catch, removed form the below code, statements around the code in each of the above mentioned functions and neither throw an exception.</p>
  <p>The main class implements the SensorEventListener interface, all variables are initialized in the partial code below:</p>
  <pre><code>private lateinit var mSensorManager : SensorManager
  private var mAccelerometer : Sensor ?= null
  private var resume = false;
  
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
  
      mSensorManager = getSystemService(Context.SENSOR_SERVICE) as SensorManager
      val deviceSensors: List&lt;Sensor&gt; = mSensorManager.getSensorList(Sensor.TYPE_ALL)
      mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)
  }
  
  override fun onSensorChanged(event: SensorEvent?) {
      if (event != null) {
          if (event.sensor.type == Sensor.TYPE_ACCELEROMETER) {
              findViewById&lt;TextView&gt;(R.id.sensor_value_accelx).text =
                  event.values[0].toString()
          }
      }
  }
  
  
  override fun onResume() {
      super.onResume()
      mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_STATUS_ACCURACY_LOW)
  }
  
  override fun onPause() {
      super.onPause()
      mSensorManager.unregisterListener(this, mAccelerometer)
  }
  </code></pre>
  <p>Any help in where to look for the problem or any ideas on how to solve the issue would be very helpful.</p>
  <p>I did some digging and found that there is a thing called Logcat.
  Here is the error that it reports:</p>
  <blockquote>
  <blockquote>
  <p>2020-10-02 14:35:28.604 11040-11040/com.example.sensors E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.example.sensors, PID: 11040
  kotlin.NotImplementedError: An operation is not implemented: Not yet implemented
  at com.example.sensors.MainActivity.onAccuracyChanged(MainActivity.kt:63)
  at android.hardware.SystemSensorManager$SensorEventQueue.dispatchSensorEvent(SystemSensorManager.java:835)
  at android.os.MessageQueue.nativePollOnce(Native Method)
  at android.os.MessageQueue.next(MessageQueue.java:335)
  at android.os.Looper.loop(Looper.java:183)
  at android.app.ActivityThread.main(ActivityThread.java:7656)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)</p>
  </blockquote>
  </blockquote>
  <p>What does this mean?</p>