I have a background service which runs in the background tracking device location using a PendingIntent
.
The service calls mFusedLocationClient.requestLocationUpdates(mLocationRequest, locationRequest, pendingIntent
) to start location tracking but also sometimes to update the location tracking (change the frequency of updates).
Should I store the GoogleApiClient
instance in the service class or should I connect to it each time I need it?
I'm worried if I store it, disconnection can appear. This shouldn't be a problem in theory because the documentation says
GoogleApiClient
automatically tries to reconnect itself.If I connect each time to
GoogleApiClient
, it adds a bit of complexity in the code, because the connection made withconnect()
is asynchronous.
Based on your experience, what do you think is best?