Hello,
You have this:
...
private SensorEvent lastEvent;
...
@Override
public void onSensorChanged(SensorEvent event) {
if (lastEvent == null) {
lastEvent = event;
return;
}
Log.v(TAG, "dT [" + Thread.currentThread().getName() + "]: " +
(event.timestamp - lastEvent.timestamp));
}
----------------
The problem is that the "onSensorChanged()" method can be invoked
concurrently because it is an event listener.
Declare a local variable and copy the value (not just a pointer to the
object):
@Override
public void onSensorChanged(SensorEvent event) {
...
int lastTimestamp = event.timestamp;
...
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en