tags:

views:

332

answers:

1

Yes, I can get sensor update events with SensorEventListener. But this approach has 2 drwwbacks:

1) For some sensors I have to wait for the state to update. For example, temperature may update after a minute!

2) In some cases I can get incorrect readings. For example, the phone lies on a flat surface and does not move. I receive first orientation update event after listener registration. When only a part of the orientation vector changes, other parts may be 0. And it is no way to determine, is it a true 0 degree azimuth or just an incomplete vector. If I move the phone a little, the correct non-zero azimuth appears.

To solve this problems it's possible to create a separate thread that constantly monitors sensors. After some time it will certainly contain true values. But I think that it is an overhead for such simple task.

Is it any other way to get current sensor data?

+1  A: 

Is it any other way to get current sensor data?

Not in the current API, AFAIK, sorry.

CommonsWare