Location set - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:set
    public long getStatusUpdateTime() { 
        return mStatusUpdateTime;
    } 
 
    public void setLocation(Location l) {
        mLocation.set(l);
        mHasLocation = true;
        if (mEnabled) {
            try { 
                mLocationManager.reportLocation(mLocation, false);
            } catch (RemoteException e) {
                Log.e(TAG, "RemoteException calling reportLocation");
            } 
        } 
    } 
 
    public void clearLocation() { 
        mHasLocation = false;
    } 
 
7
CodeRank
This code example shows how to use the following methods:set
        } 
        return true; 
    } 
 
    public void setLocation(Location l) {
        mLocation.set(l);
        mHasLocation = true;
        try { 
            mLocationManager.reportLocation(mLocation, false);
        } catch (RemoteException e) {
            Log.e(TAG, "RemoteException calling reportLocation");
        } 
    } 
 
    public void clearLocation() { 
        mHasLocation = false;
    } 
 
    public void setStatus(int status, Bundle extras, long updateTime) {
        mStatus = status;
6
CodeRank
This code example shows how to use the following methods:set
    public boolean supportsSpeed() { 
        return mSupportsSpeed;
    } 
 
    public void setLocation(Location l) {
        mLocation.set(l);
        mHasLocation = true;
        try { 
            mLocationManager.reportLocation(mLocation);
        } catch (RemoteException e) {
            Log.e(TAG, "RemoteException calling reportLocation");
        } 
    } 
 
    public void clearLocation() { 
        mHasLocation = false;
    } 
 
    public void setStatus(int status, Bundle extras, long updateTime) {
        mStatus = status;
5
CodeRank
This code example shows how to use the following methods:getProvider, getTime, set
        if (!mHaveLocation) {
            mHaveLocation = true;
        } 
 
        long now = SystemClock.uptimeMillis();
        if (location.getTime() < System.currentTimeMillis()) {
            now -= System.currentTimeMillis() - location.getTime();
        } 
        boolean useLocation = false;
        final String provider = location.getProvider();
        if (LocationManager.GPS_PROVIDER.equals(provider)) {
            // Use GPS if available 
            mLastGpsFixTime = now;
            useLocation = true;
        } else if (LocationManager.NETWORK_PROVIDER.equals(provider)) {
            // Use network provider if GPS is getting stale 
            useLocation = now - mLastGpsFixTime > RETAIN_GPS_MILLIS;
            if (mNetworkLocation == null) {
                mNetworkLocation = new Location(location);
            } else { 

5
CodeRank
This code example shows how to use the following methods:set
    public boolean supportsSpeed() { 
        return mSupportsSpeed;
    } 
 
    public void setLocation(Location l) {
        mLocation.set(l);
        mHasLocation = true;
        try { 
            mLocationManager.reportLocation(mLocation, false);
        } catch (RemoteException e) {
            Log.e(TAG, "RemoteException calling reportLocation");
        } 
    } 
 
    public void clearLocation() { 
        mHasLocation = false;
    } 
 
    public void setStatus(int status, Bundle extras, long updateTime) {
        mStatus = status;
5
CodeRank
This code example shows how to use the following methods:getAccuracy, getAltitude, getLatitude, getLongitude, getProvider
     * Set Location. 
     * 
     * @param location New location 
     */ 
    public void setLocation(final Location location) {
        mLocation.set(location);
        mHasLocation = true;
    } 
 
    /** 
     * Save stored location in Shared Preferences. 
     * 
     * @param location New location 
     */ 
    public final void save(final Location location) {
        setLocation(location);
        save(); 
    } 
 
    /** 

5
CodeRank
This code example shows how to use the following methods:set, setTime
		} 
	} 
 
	private void updateLocation(Location loc) {
		// Actualizar lastLocation 
		lastLocation.set(loc);
		// Cambio la fecha por el bug detectado en la fecha UTC de los gps de Samsung Galaxy 
    	Date now = new Date();
        long tt=now.getTime();
        lastLocation.setTime(tt);
    	main.updateLocation(lastLocation);
    	// Actualizar numero de puntos leidos 
    	numpuntos++;
	} 
	 
	// 
	// locationListener 
	// 
	LocationListener locationListener = new LocationListener() {
	    public void onLocationChanged(Location loc) { 
5
CodeRank
This code example shows how to use the following methods:set
   * Updates current user location for measuring. 
   * 
   * @param location user's current location 
   */ 
  public void setUserLocation(Location location) {
    userLocation.set(location);
  } 
 
  @Override 
  protected void onDraw(Canvas canvas) {
    if (userLocation == null || !userLocation.hasAccuracy() || displayState == null) {
      return; 
    } 
    // Figure out distance from user location to screen center point 
    float[] mapLonLat = displayState.getScreenCenterGeoLocation();
    screenCenterLocation.setLatitude(mapLonLat[1]);
    screenCenterLocation.setLongitude(mapLonLat[0]);
    int distanceM = Math.round(userLocation.distanceTo(screenCenterLocation));
    int accuracyM = Math.round(userLocation.getAccuracy());
 
4
CodeRank

Related Location set Questions & Answers:

set Method Overview
Sets the contents of the location to the values from the given location.
See Code Examples for other Android Location Methods: