Android LocationListener - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android LocationListener class.

This code example shows how to use the following methods:onLocationChanged
 
            String key = LocationManager.KEY_LOCATION_CHANGED; 
            Location location = (Location)intent.getExtras().get(key); 
 
            if (locationListener != null && location != null) 
                locationListener.onLocationChanged(location); 
 
            locationManager.removeUpdates(singleUpatePI); 
        } 
    }; 
 
    /** 
     * {@inheritDoc} 
     */ 
    public void setChangedLocationListener(LocationListener l) {
        locationListener = l;
    } 
 
    /** 
     * {@inheritDoc} 
6
CodeRank
This code example shows how to use the following methods:onLocationChanged
		locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
	} 
 
	@Override 
	public void onLocationChanged(Location location) {
		listener.onLocationChanged(isBetterLocation(location)?location:currentBestLocation);
 
	} 
 
	@Override 
	public void onProviderDisabled(String provider) {
		listener.onProviderDisabled(provider);
 
	} 
 
	@Override 
	public void onProviderEnabled(String provider) {
		listener.onProviderEnabled(provider);
 
	} 
4
CodeRank
This code example shows how to use the following methods:onLocationChanged
	   */ 
	  protected LocationListener singeUpdateListener = new LocationListener() {
	    public void onLocationChanged(Location location) { 
	      Log.d(TAG, "Single Location Update Received: " + location.getLatitude() + "," + location.getLongitude()); 
	      if (locationListener != null && location != null) 
	        locationListener.onLocationChanged(location); 
	      locationManager.removeUpdates(singeUpdateListener); 
	    } 
	     
	    public void onStatusChanged(String provider, int status, Bundle extras) {} 
	    public void onProviderEnabled(String provider) {}     
	    public void onProviderDisabled(String provider) {} 
	  }; 
	   
	  /** 
	   * {@inheritDoc} 
	   */ 
	  public void setChangedLocationListener(LocationListener l) {
	    locationListener = l;
	  } 
4
CodeRank
This code example shows how to use the following methods:onLocationChanged
 
            String key = LocationManager.KEY_LOCATION_CHANGED; 
            Location location = (Location) intent.getExtras().get(key); 
 
            if(locationListener != null && location != null) { 
                locationListener.onLocationChanged(location); 
            } 
 
            locationManager.removeUpdates(singleUpdatePI); 
        } 
    }; 
 
    @Override 
    public void setChangedLocationListener(LocationListener listener) {
        locationListener = listener;
    } 
 
    @Override 
    public void cancel() { 
        locationManager.removeUpdates(singleUpdatePI);
4
CodeRank
This code example shows how to use the following methods:onLocationChanged
 
    @Test 
    public void testOnLocationChanged() { 
        Location location = createMock(Location.class);
        expect(mLocationControlBuffered.getLocation()).andReturn(location);
        locationListener.onLocationChanged(location);
        expect(activityVisible.getVisible()).andReturn(true);
 
        replayAll(); 
        new CombinedLocationListener(mLocationControlBuffered, null, activityVisible)
                .onLocationChanged(location);
        verifyAll(); 
    } 
 
    @Test 
    public void testOnProviderDisabled() { 
        locationListener.onProviderDisabled("gps");
        expect(activityVisible.getVisible()).andReturn(true);
 
        replayAll(); 
4
CodeRank
This code example shows how to use the following methods:onLocationChanged
			 
			String key = LocationManager.KEY_LOCATION_CHANGED; 
			Location location = (Location)intent.getExtras().get(key); 
			 
			if (locationListener != null && location != null) 
				locationListener.onLocationChanged(location); 
			 
			locationManager.removeUpdates(singleUpatePI); 
		} 
	}; 
	 
	@Override 
	public void setChangedLocationListener(LocationListener l) {
		locationListener = l;
	} 
 
	@Override 
	public void cancel() { 
		locationManager.removeUpdates(singleUpatePI);
	} 
4
CodeRank
This code example shows how to use the following methods:onLocationChanged
   
  protected LocationListener singeUpdateListener = new LocationListener() {
    public void onLocationChanged(Location location) { 
      Log.d(TAG, "Single Location Update Received: " + location.getLatitude() + "," + location.getLongitude()); 
      if (locationListener != null && location != null) 
        locationListener.onLocationChanged(location); 
      locationManager.removeUpdates(singeUpdateListener); 
    } 
     
    public void onStatusChanged(String provider, int status, Bundle extras) {} 
    public void onProviderEnabled(String provider) {}     
    public void onProviderDisabled(String provider) {} 
  }; 
   
  /** 
   * {@inheritDoc} 
   */ 
  public void setChangedLocationListener(LocationListener l) {
    locationListener = l;
  } 
4
CodeRank
This code example shows how to use the following methods:onLocationChanged
This code example shows how to use the following methods:onLocationChanged
        // not be this one). 
        // Log.d("GeoBeagle", "onLocationChanged:" + location); 
        final Location chosenLocation = mLocationControlBuffered.getLocation();
        // Log.d("GeoBeagle", "onLocationChanged chosen Location" + 
        // chosenLocation); 
        mLocationListener.onLocationChanged(chosenLocation);
    } 
 
    public void onProviderDisabled(String provider) {
        mLocationListener.onProviderDisabled(provider);
    } 
 
    public void onProviderEnabled(String provider) {
        mLocationListener.onProviderEnabled(provider);
    } 
 
    public void onStatusChanged(String provider, int status, Bundle extras) {
        mLocationListener.onStatusChanged(provider, status, extras);
    } 
} 
4
CodeRank
This code example shows how to use the following methods:onLocationChanged
  } 
 
  @Override 
  public synchronized void onLocationChanged(Location location) {
    //super.onLocationChanged(location); 
    mListener.onLocationChanged(location);
  } 
   
   
 
} 
4
CodeRank

Related Android LocationListener Questions & Answers:

Other Android LocationListener Examples

10:	import android.widget.Toast;
11:	
12:	public class ShowLocationActivity extends Activity implements LocationListener {
13:	  private TextView latituteField;
14:	  private TextView longitudeField;

Read More

13:	import android.util.Log;
14:	
15:	public class GPSTracker extends Service implements LocationListener {
16:	
17:		private final Context mContext;

Read More

13:	import android.util.Log;
14:	
15:	public class GPSTracker extends Service implements LocationListener {
16:	
17:		private final Context mContext;

Read More

See Code Examples for Android LocationListener Methods: