Ответ 1
Я решил это.
float azimuth = // get azimuth from the orientation sensor (it quite simple)
Location currentLoc = // get location from GPS or network
// convert radians to degrees
azimuth = Math.toDegrees(azimuth);
GeomagneticField geoField = new GeomagneticField(
(float) currentLoc.getLatitude(),
(float) currentLoc.getLongitude(),
(float) currentLoc.getAltitude(),
System.currentTimeMillis());
azimuth += geoField.getDeclination(); // converts magnetic north to true north
float bearing = currentLoc.bearingTo(target); // (it already in degrees)
float direction = azimuth - bearing;
Если вы собираетесь нарисовать стрелку или что-то еще, чтобы указать направление, используйте canvas.rotate(-direction). Мы передаем отрицательный аргумент, потому что вращение холста против часовой стрелки.