delight-im/Android-SimpleLocation

Works only first time then It does not work

Closed this issue · 1 comments

Here is exemple code:

location = new SimpleLocation(this);

    // if we can't access the location yet
if (!location.hasLocationEnabled()) {
        // ask the user to enable location access
        SimpleLocation.openSettings(this);
    }

location.beginUpdates();

location.setListener(new SimpleLocation.Listener() {
        public void onPositionChanged() {
            Log.d("Location", location.getLatitude()+":"+location.getLongitude()+":"+location.getAltitude());
        }
});

When I open emulator and change Latitude or Longitude first time it fires listener but then it does not.

ocram commented

The emulator is always different than a real device. So make sure to check on a real device as well, if you get a chance.

Apart from that, please try the extended constructor variants that let you specify an update interval manually.

Finally, if location isn’t enabled (and you open the settings), starting the location updates doesn’t make any sense. But if the user returns from the settings, e.g. in onResume, it might make sense to start the updates again.

Hope that helps!