0

When I'm using the LocationManager on my phone, for almost all the Nexus 5 test devices the LocationManager detects the same location a couple of times every minute (I'm listening for the location every 60 seconds). To be clear the code I'm actually using:

    mLocationManager.requestLocationUpdates(60*1000,
            0,
            criteria),
            mLocationUpdateListener, Looper.getMainLooper());

the criteria is set from the server and only defines the desired accuracy (Criteria.ACCURACY_COARSE or Criteria.ACCURACY_FINE).

So for my other test devices (Nexus 4 and a Samsung S3) I have no problem with the location manager. It always delivers a new position every 60 seconds. But the Nexus 5 devices seem to cache the position at some point, so that I send the exact same location 5 times to the server even though I'm already a few 100 meter away from that location.

Does anybody have a clue what could be the problem? If you're interested, I could also append the code for mLocationUpdateListener, but it just sends the location to the server.

Edit: the location is always obtained in a background service. I could overcome this problem by opening Google Maps in the foreground. But of course that can not be the solution to my problem.

Edit solution: It seems like somehow the Play Services didn't work on all 6 Nexus 5 test devices. After restarting all devices, I couldn't reproduce that weird behavior anymore...

Edit 2: and again I stumble upon this behavior and it keeps appearing even though I restart the phones...

Stefan Medack
  • 2,731
  • 26
  • 32

1 Answers1

0

try this one

mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mLocationUpdateListener);

Ramki Anba
  • 754
  • 1
  • 10
  • 21
  • Hey Ramki, thanks for your reply. I'm aware that I could use GPS_PROVIDER or NETWORK_PROVIDER directly, but I've chosen this approach because I want to use the fusion provider from Google. Which provider delivers the location is pretty much not important, but indoors GPS can not obtain a fix and outdoors Network sometimes just doesn't work out. That's why I decided for the fusion provider. – Stefan Medack May 28 '14 at 12:44
  • In Nexus 5 enable the Location Service. Otherwise you get the last known location only. – Ramki Anba May 28 '14 at 12:53
  • You mean in Settings? That is enabled on High Accuracy (the same as on my Nexus 4 which does not have this particular error) – Stefan Medack May 28 '14 at 13:08
  • 1
    Yes, try to restart your device and check it once again – Ramki Anba May 28 '14 at 13:12
  • I'm not quite sure if the error can be fixed with restarting my 6 Nexus 5 phones which all have exactly the same error... – Stefan Medack May 28 '14 at 13:22
  • Just try it. If location service has a problem it'll resolved. – Ramki Anba May 28 '14 at 13:36
  • Looks like restarting did the job. Thank a lot – Stefan Medack May 28 '14 at 16:16