Method LocationListener.onLocationChanged in a separate service is not called after the activity, which launched the service is destroyed.
in the onCreate method off activity:
locationService = new Intent(this, LocationService.class);
locationService.putExtra("MESSENGER", new Messenger(messageHandler));
startService(locationService);
after this code service is never stopped in activity.
While activity is running, location updates recieved correctly.
After destroing the activity, service stay ranning, but location updates not recieved.
in the LocationService class
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
locationProvider = locationManager.getBestProvider(criteria, false);
locationManager.requestLocationUpdates(locationProvider, 0, 0, this);