Google play services and setInterval

0

I'm trying to use google play service to get the user's position. The problem is this, I have dynamic time interval for sending this position to the server. However, LocationClient does not respect this interval, regardless of the value it has, the position update occurs in a fixed interval of 5 s.

Could anyone help me?

The code:

private LocationClient locationClient;

public void iniciarBusca(long updateInterval, long fastestInterval) {
    mLocationRequest = LocationRequest.create();

    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    mLocationRequest.setInterval(updateInterval);
    mLocationRequest.setFastestInterval(fastestInterval);

    locationClient = new LocationClient(activity, this, this);      
    locationClient.connect();
}

public void disconectar() {
    try {
        locationClient.disconnect();
    } catch (Exception e) {
    }
}
    
asked by anonymous 05.12.2014 / 17:39

1 answer

1

Hello, my first tip is that you put connect and disconnect inside onPause and onResume like this:

    @Override
    protected void onResume() {
        super.onResume();
        locationClient.connect();
    }

    @Override
    protected void onPause() {
        super.onPause();
        locationClient.disconnect();
    }

And about the range I did not quite understand its intention because the value of updateInterval and fastestInterval is equal to zero, because you did not put value to them just set them as setInterval and setFastestInterval .

Correct me if I'm wrong. A hug.

    
05.12.2014 / 23:38