LocationManager getLastKnownLocation - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for LocationManager getLastKnownLocation method.

This code example shows how to use the following methods:getLastKnownLocation
		cLoc = mLocMan.getLastKnownLocation(LocationManager.GPS_PROVIDER);
	} 
	 
	public Location getLocation()
	{ 
		cLoc = mLocMan.getLastKnownLocation(LocationManager.GPS_PROVIDER);
		return cLoc;
	} 
	 
	public void onProviderDisabled(String provider) {
		// TODO Auto-generated method stub 
		Log.d(LOG_TAG, "The provider " + provider + " is disabled");
		owner.fail();
	} 
 
	public void onProviderEnabled(String provider) {
		// TODO Auto-generated method stub 
		Log.d(LOG_TAG, "The provider "+ provider + " is enabled");
	} 
 
10
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getLastKnownLocation
		cLoc = mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
	} 
	 
	public Location getLocation()
	{ 
		cLoc = mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
		return cLoc;
	} 
 
	public void onProviderDisabled(String provider) {
		// TODO Auto-generated method stub 
		Log.d(LOG_TAG, "The provider " + provider + " is disabled");
	} 
 
 
	public void onProviderEnabled(String provider) {
		// TODO Auto-generated method stub 
		Log.d(LOG_TAG, "The provider "+ provider + " is enabled");
	} 
 
10
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getLastKnownLocation, isProviderEnabled, requestLocationUpdates
	 
	 
	@Override 
	public void async(Context context){
		lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);		
		gpsEnabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
		networkEnabled = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
		work(); 
	} 
	 
	public LocationAjaxCallback timeout(long timeout){
		this.timeout = timeout;
		return this;
	} 
	 
	public LocationAjaxCallback accuracy(float accuracy){
		this.accuracy = accuracy;
		return this;
	} 
	 

9
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getLastKnownLocation, isProviderEnabled, requestLocationUpdates
			locationManager = (LocationManager) mContext
					.getSystemService(LOCATION_SERVICE);
 
			// getting GPS status 
			isGPSEnabled = locationManager
					.isProviderEnabled(LocationManager.GPS_PROVIDER);
 
			// getting network status 
			isNetworkEnabled = locationManager
					.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
 
			if (!isGPSEnabled && !isNetworkEnabled) {
				// no network provider is enabled 
			} else { 
				this.canGetLocation = true;
				if (isNetworkEnabled) {
					locationManager.requestLocationUpdates(
							LocationManager.NETWORK_PROVIDER,
							MIN_TIME_BW_UPDATES,
							MIN_DISTANCE_CHANGE_FOR_UPDATES, this);

8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getLastKnownLocation, isProviderEnabled, requestLocationUpdates
     * @param myLocationFoundListener the callback 
     */ 
    public void requestLocationUpdates(MyLocationFoundListener myLocationFoundListener) {
        mMyLocationFoundListener = myLocationFoundListener;
 
        if (mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
            mGpsLocationListener = new MyLocationListener();
            mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
                    0, 0, mGpsLocationListener);
        } 
 
        if (mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
            mNetworkLocationListener = new MyLocationListener();
            mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
                    0, 0, mNetworkLocationListener);
        } 
 
        if (mNetworkLocationListener != null || mGpsLocationListener != null) {
            mLocationRequestTimeOut.start();
        } else { 

8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getBestProvider, getLastKnownLocation
-66
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getLastKnownLocation, isProviderEnabled
		mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
	} 
	 
	private boolean isGpsLocationProviderEnabled() { 
		try { 
        	return mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        } catch (Exception e) {
        	DebugLog.d(TAG, e.getMessage());
        } 
		 
		return false; 
	} 
	 
	private boolean isNetworkLocationProviderEnabled() { 
		try { 
        	return mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
        } catch (Exception e) {
        	DebugLog.d(TAG, e.getMessage());
        } 
		 

5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getLastKnownLocation, isProviderEnabled, requestLocationUpdates
			locationManager = (LocationManager) mContext
					.getSystemService(LOCATION_SERVICE);
 
			// getting GPS status 
			isGPSEnabled = locationManager
					.isProviderEnabled(LocationManager.GPS_PROVIDER);
 
			// getting network status 
			isNetworkEnabled = locationManager
					.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
 
			if (!isGPSEnabled && !isNetworkEnabled) {
				// no network provider is enabled 
			} else { 
				this.canGetLocation = true;
				if (isNetworkEnabled) {
					locationManager.requestLocationUpdates(
							LocationManager.NETWORK_PROVIDER,
							MIN_TIME_BW_UPDATES,
							MIN_DISTANCE_CHANGE_FOR_UPDATES, this);

8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getBestProvider, getLastKnownLocation, isProviderEnabled, requestLocationUpdates
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getLastKnownLocation, isProviderEnabled, requestLocationUpdates
        locationManager = (LocationManager) mContext
                .getSystemService(LOCATION_SERVICE);
 
        // getting GPS status 
        isGPSEnabled = locationManager
                .isProviderEnabled(LocationManager.GPS_PROVIDER);
 
        // getting network status 
        isNetworkEnabled = locationManager
                .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
 
        if (!isGPSEnabled && !isNetworkEnabled) {
            // no network provider is enabled 
        } else { 
            this.canGetLocation = true;
            if (isNetworkEnabled) {
                locationManager.requestLocationUpdates(
                        LocationManager.NETWORK_PROVIDER,
                        MIN_TIME_BW_UPDATES,
                        MIN_DISTANCE_CHANGE_FOR_UPDATES, this);

7
CodeRank
Experience pair programming with AI  Get Codota for Java

Related LocationManager getLastKnownLocation Questions & Answers:

Other LocationManager getLastKnownLocation Examples

30:	    Criteria criteria = new Criteria();
31:	    provider = locationManager.getBestProvider(criteria, false);
32:	    Location location = locationManager.getLastKnownLocation(provider);
33:	
34:	    // Initialize the location fields

Read More

69:						if (locationManager != null) {
70:							location = locationManager
71:									.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
72:							if (location != null) {
73:								latitude = location.getLatitude();
-
86:							if (locationManager != null) {
87:								location = locationManager
88:										.getLastKnownLocation(LocationManager.GPS_PROVIDER);
89:								if (location != null) {
90:									latitude = location.getLatitude();

Read More

70:						if (locationManager != null) {
71:							location = locationManager
72:									.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
73:							if (location != null) {
74:								latitude = location.getLatitude();
-
87:							if (locationManager != null) {
88:								location = locationManager
89:										.getLastKnownLocation(LocationManager.GPS_PROVIDER);
90:								if (location != null) {
91:									latitude = location.getLatitude();

Read More

getLastKnownLocation Method Overview
Returns a Location indicating the data from the last known location fix obtained from the given provider.
See Code Examples for other Android LocationManager Methods: