0

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.

Wrong
  • 1,195
  • 2
  • 14
  • 38
  • You could consider using the bearing from the GPS updates. – Markus Kauppinen Oct 03 '18 at 12:12
  • the problem is that it returns always 0.0 bec I don't have gyroscope I guess, so I am using this simulated gyroscope but can't make it work the way I want https://forum.xda-developers.com/showpost.php?p=67774783&postcount=4 , Since I guess what I need is some kind of gyro @MarkusKauppinen – Wrong Oct 03 '18 at 12:28
  • 1
    GPS bearing isn't dependent on the gyroscope. And they are useful in different use cases anyway. Gyroscope could tell you in realtime how the user is rotating the phone while standing still but nothing about the magnetic north, the magnetometer (as a compass) could tell you where the magnetic north is related to the phone's orientation and the GPS bearing will tell you the latest direction of the movement of the device independent of the orientation or rotation of the phone. So, you'll need to decide what it is that you need. Possibly several of those. – Markus Kauppinen Oct 03 '18 at 12:34
  • @MarkusKauppinen I have a position marker that is always pointing up, when the user turns 45º the marker will too and when the user turns 90º (left or right) the marker will again point up and the map will turn instead. So don't I only need to know when the phone is rotating? Do I need the compass for that or something else? Anyways I've tried lots of things: compass, orientation and motion and couldn't achieve it yet. – Wrong Oct 03 '18 at 12:38
  • 1
    Sounds like you need a compass. That's done with the combination of the magnetometer and the accelerometer and isn't exactly trivial, so better look at some tutorials or popular answers here on SO. Some rotation matrices and whatnot should be used for good results. [Here's something.](https://stackoverflow.com/questions/16317599/android-compass-that-can-compensate-for-tilt-and-pitch) – Markus Kauppinen Oct 03 '18 at 12:51
  • Okay thanks @MarkusKauppinen , I'll check it out – Wrong Oct 03 '18 at 12:55

0 Answers0