Code example for GeomagneticField

Methods: getDeclination

0
		if (timestamp == 0) {
			// Hack for Samsung phones which don't populate the time field 
			timestamp = System.currentTimeMillis();
		} 
 
		GeomagneticField field = new GeomagneticField(
				(float) location.getLatitude(),
				(float) location.getLongitude(),
				(float) location.getAltitude(), timestamp);
		variation = field.getDeclination();
		 
//		Log.d("MyLocationService", "Variation reset to " + variation + " degrees."); 
	} 
 
	@Override 
	public void onAccuracyChanged(Sensor sensor, int accuracy) {
		// do nothing 
	} 
 
	@Override