i am developing a application which will send location updates continuously from a background service. i tried following code.
public class LocationService e
Is it working fine in background? Service does not stops after 45 mins while running in the background ? – Noman Nov 3 '15 at 6:18
It's a good comment. I had some proglem with the location update long continious in my project. And it really stopped after 45 minutes.
My service is foreground. I using
StartForeground(ServicesId.Push, notification);
And I every 45 minutes wake up location update
_timer = new Timer(); _timer.Schedule(new TimerTaskTrek(this), 45 * 60 * 1000 + 10 * 1000, 45 * 60 * 1000 + 10 * 1000);
And In timerTask
try {
Looper.Prepare();
} catch (Exception e) {
}
_client = new >GoogleApiClient.Builder(this).AddApi(LocationServices.API) .AddConnectionCallbacks(this) .AddOnConnectionFailedListener(this) .Build();
_client.Connect();
It's very simple and it's work very good. Enjoy