Point compass to a particular co ordinate

63 Views Asked by At


I am creating an android compass application.
However, I want to add a functionality where the compass will point to some co ordinate that I have specified.
How can I achieve this.

Thanks and Regards,
Rohit Savant

1

There are 1 best solutions below

0
On

For what you want to achieve you will need 2 Locations, your own and that of the target. Then you can use the bearingTo() method to determine the angle from you to the target:

Location me = ...
Location target = ...

float angle = me.bearingTo(target);