I am trying to get a device\'s location information using GPS, but for some reason one of the two coordinates is missing sometimes.
This is the code:
Loc
Because the GPS isn't always on. getLastKnownLocation will return a location if it knows one and if it isn't too stale. Since nothing else was using the GPS, it doesn't know one. If you need a location, either requestLocationUpdates or requestSingleUpdate, which will turn on the GPS and get a new location.