org.osmdroid.util.NetworkLocationIgnorer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of osmdroid-android Show documentation
Show all versions of osmdroid-android Show documentation
An Android library to display OpenStreetMap views.
package org.osmdroid.util;
import org.osmdroid.util.constants.UtilConstants;
import android.location.LocationManager;
/**
*
* A class to check whether we want to use a location. If there are multiple location providers,
* i.e. network and GPS, then you want to ignore network locations shortly after a GPS location
* because you will get another GPS location soon.
*
* @author Neil Boyd
*
*/
public class NetworkLocationIgnorer implements UtilConstants {
/** last time we got a location from the gps provider */
private long mLastGps = 0;
/**
* Whether we should ignore this location.
*
* @param pProvider
* the provider that provided the location
* @param pTime
* the time of the location
* @return true if we should ignore this location, false if not
*/
public boolean shouldIgnore(final String pProvider, final long pTime) {
if (LocationManager.GPS_PROVIDER.equals(pProvider)) {
mLastGps = pTime;
} else {
if (pTime < mLastGps + GPS_WAIT_TIME) {
return true;
}
}
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy