Which thread invokes SensorEventListener.onSensorChanged

Posted by Christoph Heindl on Stack Overflow See other posts from Stack Overflow or by Christoph Heindl
Published on 2010-05-04T05:44:04Z Indexed on 2010/05/04 5:48 UTC
Read the original article Hit count: 308

Filed under:
|

From my records it seems that SensorEventListener.onSensorChanged callback is called by the same thread that registered the callback. I.e there must be some message-queue synchronization going on in the background which allows the activitys UI-Thread to handle the callbacks.

That leads to my question: Is there a need to synchronize SensorEventListener.onSensorChanged with the activitys UI-thread, assuming that the activitys UI-thread registered the SensorEventListener?

I cannot find any documentation references, but can see various examples calling invalidate() unsychronized or synchronize the entire callback.

I used something along the lines of

Log.i(TAG, "" + Thread.currentThread().getId()); 

to retrieve threading information.

I'm running android 2.1 update1.

Best regards, Christoph

© Stack Overflow or respective owner

Related posts about android

Related posts about java