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

StackOverflow https://stackoverflow.com/questions/12910941

質問

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 ?

役に立ちましたか?

解決

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.

他のヒント

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top