android- which Thread does run onSensorChanged?

if I attach a listener to a sensor of the device (like below), in this situation while onSensorChanged happens, which thread does run generateNewRotation method, main Thread or…?

SensorEventListener sensorListener = new SensorEventListener() {

        @Override
        public void onSensorChanged(SensorEvent event) {

            generateNewRotation();
        }

        @Override
        public void onAccuracyChanged(Sensor sensor, int accuracy) {
        }
    };

Answer

OnSensorChanged() gets called inside the Main Thread, also called the UI Thread.

Leave a Reply

Your email address will not be published. Required fields are marked *