Code example for Location

Methods: bearingTodistanceTogetAltitudegetLatitudegetLongitudegetSpeedtoString

0
 
	} 
 
	private void calculateDestinationAndBearing() { 
		if (null != mDestination && null != mMapCenter) {
			final int distance = (int) mMapCenter.distanceTo(mDestination);
			mRadarView.setBearing(mMapCenter.bearingTo(mDestination));
			mTextViewDistance.setText(Util.buildDistanceString(distance));
			if (mLastLocation != null) {
				mTextViewSpeed.setText(Util.buildSpeedString(mLastLocation.getSpeed()));
			} 
		} 
	} 
 
	/********************************************* 
	 * GPS Callbacks 
	 *********************************************/ 
 
	@Override 
	public void onLocationChanged(final Location location) {
		Log.i("RadarActivity", location.toString());
		mLastLocationMillis = SystemClock.elapsedRealtime();
		mLastLocation = location;
		GeomagneticField geoField = new GeomagneticField(Double.valueOf(location.getLatitude()).floatValue(), Double.valueOf(location.getLongitude()).floatValue(), Double.valueOf(location.getAltitude()).floatValue(), System.currentTimeMillis());
		mRadarView.setDeclination(geoField.getDeclination());
		mMapCenter = location;
		calculateDestinationAndBearing(); 
	}