Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public class

GeomagneticField

extends Object
java.lang.Object
   ↳ android.hardware.GeomagneticField

Class Overview

Estimates magnetic field at a given point on Earth, and in particular, to compute the magnetic declination from true north.

This uses the World Magnetic Model produced by the United States National Geospatial-Intelligence Agency. More details about the model can be found at http://www.ngdc.noaa.gov/geomag/WMM/DoDWMM.shtml . This class currently uses WMM-2010 which is valid until 2015, but should produce acceptable results for several years after that. Future versions of Android may use a newer version of the model.

Summary

Public Constructors
GeomagneticField (float gdLatitudeDeg, float gdLongitudeDeg, float altitudeMeters, long timeMillis)
Estimate the magnetic field at a given point and time.
Public Methods
float getDeclination ()
float getFieldStrength ()
float getHorizontalStrength ()
float getInclination ()
float getX ()
float getY ()
float getZ ()
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public GeomagneticField (float gdLatitudeDeg, float gdLongitudeDeg, float altitudeMeters, long timeMillis)

Added in API level 3

Estimate the magnetic field at a given point and time.

Parameters
gdLatitudeDeg Latitude in WGS84 geodetic coordinates -- positive is east.
gdLongitudeDeg Longitude in WGS84 geodetic coordinates -- positive is north.
altitudeMeters Altitude in WGS84 geodetic coordinates, in meters.
timeMillis Time at which to evaluate the declination, in milliseconds since January 1, 1970. (approximate is fine -- the declination changes very slowly).

Public Methods

public float getDeclination ()

Added in API level 3

Returns
  • The declination of the horizontal component of the magnetic field from true north, in degrees (i.e. positive means the magnetic field is rotated east that much from true north).

public float getFieldStrength ()

Added in API level 3

Returns
  • Total field strength in nanoteslas.

public float getHorizontalStrength ()

Added in API level 3

Returns
  • Horizontal component of the field strength in nonoteslas.

public float getInclination ()

Added in API level 3

Returns
  • The inclination of the magnetic field in degrees -- positive means the magnetic field is rotated downwards.

public float getX ()

Added in API level 3

Returns
  • The X (northward) component of the magnetic field in nanoteslas.

public float getY ()

Added in API level 3

Returns
  • The Y (eastward) component of the magnetic field in nanoteslas.

public float getZ ()

Added in API level 3

Returns
  • The Z (downward) component of the magnetic field in nanoteslas.