I would like to know if there is any way to get the last location of GPS , before I run the option to execute obtaining the current position.
public class Localization{
private GetGPSResponse delegate = null;
public void setDelegate(GetGPSResponse delegate){
this.delegate = delegate;
}
//Método que faz a leitura de fato dos valores recebidos do GPS
public void startGPS(Object local, final Context context){
final LocationManager lManager = (LocationManager) local ;
LocationListener lListener = new LocationListener() {
public void onLocationChanged(Location locat) {
if( locat != null ) {
delegate.getGPSResponse(locat);
lManager.removeUpdates(this);
}
}
@Override
public void onStatusChanged(String arg0, int arg1, Bundle arg2) {}
@Override
public void onProviderEnabled(String arg0) {}
@Override
public void onProviderDisabled(String arg0) {}
};
lManager.requestSingleUpdate(LocationManager.GPS_PROVIDER, lListener, null);
}
interface GetGPSResponse{
void getGPSResponse(Location location);
}
}