0

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);
General Grievance
  • 4,555
  • 31
  • 31
  • 45
  • maybe because your service is stopped/killed (after the activity was destroyed), see this http://stackoverflow.com/a/4253015/4224337 – Rami Nov 16 '14 at 14:17

1 Answers1

0

This occurs only in the emulator. On a real device service continues to run and try to get a location update.