Code example for LocationManager: Finding current location

Methods: getLastKnownLocationrequestLocationUpdatesequals

0
	public LocationHandler(Activity activity) {
 
		//	 Acquire a reference to the system Location Manager 
		locationManager = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE);
		Log.e("LocationManager",
				"LM is not null ?:" + locationManager.equals(null));
 
		currentLocation = locationManager
		.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
 
		locationManager.requestLocationUpdates(
				LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
	} 
 
	// Define a listener that responds to location updates 
	LocationListener locationListener = new LocationListener() {
 
		@Override 
		public void onStatusChanged(String provider, int status, Bundle extras) { 
			// TODO Auto-generated method stub