Using getRotationMatrix and getOrientation in Android 2.1

前端 未结 2 1952
误落风尘
误落风尘 2020-12-30 12:40

I\'ve been having issues with this for far too long. This code should output dx,dy,dz for the accelerometer, and a running total of the dx. It should also output azimuth,

2条回答
  •  没有蜡笔的小新
    2020-12-30 13:16

    The reason you're getting 0.0, -0.0, -0.0 from getOrientation() is that getRotationMatrix() doesn't always get a valid result. You need to check getRotationMatrix()'s return value, which will be false if the result is invalid, or true if it succeeded.

    Added: Actually, that didn't come out right. You're getting an invalid result for the reason aganders pointed out. Checking the return value would simply be an indication that you were in fact getting an invalid result.

提交回复
热议问题