MSaudi
MSaudi

Reputation: 4652

android - Can we get the compass direction without a physical compass (e.g. using 2 GPS points ? )

my phone has no compass, can I get a compass-like direction (angle) without a physical compass (e.g. using 2 GPS points for moving pobject ? ) or any other method ?

Upvotes: 1

Views: 3268

Answers (2)

Gregory Kalabin
Gregory Kalabin

Reputation: 1788

You can use Location.getBearing to get bearing from location object obtained using LocationManager.

Also you can calculate it manually using Location.bearingTo method.

Android SDK using precise method to operate with locations. The method considers that the earth isn't flat.

Upvotes: 2

Jon Taylor
Jon Taylor

Reputation: 7905

If the device is moving then capturing multiple GPS locations can be used to get the direction of travel.

Note though that this will only give you the direction of travel, not the orientation of the device.

EDIT: If you have two points direction between those points is simple mathematics, which you can find on any number of websites. I also believe android/iOS etc have some of these functions built in to make things easier.

Upvotes: 1

Related Questions