Code example for Location

Methods: distanceTogetAccuracygetLatitudegetLongitudegetProvider

0
			//Keep track of best location 
			//Having a location > no location 
			if (bestLocation == null) 
				bestLocation = loc; 
			//GPS Location > Network Location 
			else if (bestLocation.getProvider().equals(LocationManager.NETWORK_PROVIDER) && 
					 loc.getProvider().equals(LocationManager.GPS_PROVIDER)) 
				bestLocation = loc; 
			//More accuracy > Less accuracy 
			else if (bestLocation.distanceTo(loc) > loc.getAccuracy()) { 
				bestLocation = loc; 
			} 
			Log.d(TAG, "Best location is currently: " + bestLocation.getLatitude() + ", " + bestLocation.getLongitude() + " Type of network: " + bestLocation.getProvider()); 
		} 
 
		// Functions declared for sake of interface satisfaction 
		public void onStatusChanged(String provider, int status, Bundle extras) {} 
		public void onProviderDisabled(String provider) {} 
		public void onProviderEnabled(String provider) {} 
	};