Code example for LocationManager: Finding current location

Methods: getBestProvidergetLastKnownLocationisProviderEnabled

0
		} catch (NullPointerException e) {
			e.printStackTrace();
		} 
 
		try { 
			Provider = mLocationManager.getBestProvider(mCriteria, true);
			mLocation = mLocationManager.getLastKnownLocation(Provider);
		} catch (NullPointerException e) {
			e.printStackTrace();
			Log.e("LBN", "LBN INIT PROBLEM");
		} 
 
	} 
 
	public Location requestLocationFromProvider(final String Provider,
			LocationChange mListener) {
		Location mLocation = null;
		if (mLocationManager.isProviderEnabled(Provider)) {
			mLocationManager.requestLocationUpdates(Provider, MIN_TIME,
					MIN_DISTANCE, (LocationListener) mListener);
			mLocation = mLocationManager.getLastKnownLocation(Provider);
			return mLocation;
		} 
 
		else { 
			return null; 
		} 
	} 
 
	public Location requestLoactionFromCriteria(Criteria mCriterial,
			LocationChange mListener) {
		Location mLocation = null;
		mLocationManager.requestLocationUpdates(MIN_TIME, MIN_DISTANCE,
				mCriteria, (LocationListener) mListener, null);
		mLocation = mLocationManager.getLastKnownLocation(Provider);
		return mLocation;
	} 
	 
	public Location requestLoactionFromCriteria(Criteria mCriterial,
			LocationChange mListener,int mTime,int mDistance) {
		Location mLocation = null;
		mLocationManager.requestLocationUpdates(mTime,mDistance,
				mCriteria, (LocationListener) mListener, null);
		mLocation = mLocationManager.getLastKnownLocation(Provider);
		return mLocation;
	} 
 
	public void CheckProvider() { 
		GpsEnable = mLocationManager
				.isProviderEnabled(LocationManager.GPS_PROVIDER);
		NetWorkEnable = mLocationManager
				.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
		PassiveEnable = mLocationManager
				.isProviderEnabled(LocationManager.PASSIVE_PROVIDER);
	} 
 
	public void TurnGpsAble() { 
 
		if (!GpsEnable) {