Search code examples
androidlocationmanagerdirectioncompassbearing

How to find the user moving direction using the bearing value returned by location manager?


LocationObject.getBearing() returns the horizontal direction of travel of this device[0 to 360 degree].

How to calculate the user moving direction like North, south and all from this bearing value?

Thanks in advance.


Solution

  • From the documentation:

    Returns the direction of travel in degrees East of true North. If hasBearing() is false, 0.0 is returned.

    • So 0 is north (and the degrees goes clockwise)
    • So 90 would be East
    • 180 South
    • 270 West