本文介绍了android- 哪个线程在 onSensorChanged 上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我将侦听器附加到设备的传感器(如下所示),在这种情况下,当 onSensorChanged 发生时,哪个线程会运行 generateNewRotation 方法、主线程或...?

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) {
        }
    };

推荐答案

OnSensorChanged() 在主线程(也称为 UI 线程)内被调用.

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

这篇关于android- 哪个线程在 onSensorChanged 上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-01 01:27