Android - Know when user turns to left or right

2019-08-17 07:38发布

问题:

I am making a GPS-Like App and I need to know when the user turns left or right (his heading) to change the rotation of the position marker.

I've tried this

and this

But none of them is working, the first one just randomly changes even if I haven't totally turned and the second one just works if you change the device from horizontal to vertical or viceversa.

Can someone give me a hand please?

Thanks.