2

I'm calling getLastKnownLocation for the GPS provider and it's returning null. The docs say this might happen if the provider isn't enabled, but I know it is. Is it possible for the provider to return null if no last known location exists? I don't see where the docs say "may return null if no last known location exists"

Cœur
  • 37,241
  • 25
  • 195
  • 267
joshkendrick
  • 3,497
  • 8
  • 38
  • 52

1 Answers1

16

Is it possible for the provider to return null if no last known location exists?

Yes. In fact, much of the time, it will return null, because nothing is causing GPS to acquire fixes. GPS is usually powered down to save on battery life. See Obtaining User Location for the recipe for finding your location.

I don't see where the docs say "may return null if no last known location exists"

The documentation has its flaws.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 3
    i have gps enabled previously on my device and it was giving my location, but then working on the same app with gps being disabled,i tried to get the last known location but it returns null??can you please tell why isnt it returning my last known location which was updated an hour ago @CommonsWare – Muhammad Babar Apr 15 '13 at 11:14