I want to send location even if app is in the background, for tracking the
driver location but it has to be stopped as cab arrived.
Intent svc = new Intent(this, BackgroundSoundServi.class);
startService(svc);
I want to send location even if app is in the background, for tracking the
driver location but it has to be stopped as cab arrived.
Intent svc = new Intent(this, BackgroundSoundServi.class);
startService(svc);
You should create a list of GeoPoint
s where the cab can be considered as "Arrived". Inside your Service
's onLocationChange()
method put a method that checks the distance with the current position of the cab and the destination points and you can turn off your service when the distance becomes shorter than a given radius. e.g. 100 meters. However, if you want service to start sending locations automatically when it departs, then you should not turn off the service, but just stop sending locations. The service should always check cabs position to destinations'.