Search code examples
androidgpslocationandroid-2.3-gingerbread

Android 2.3.3 Gingerbread - cannot find location


I'm using getLastKnownLocation method to find user's position, but the method always gives me null. I've been testing the method I'm using on different system versions (for example 2.2.1, 4.0.4) and everything works fine. On 2.3.3 I always get null, not even once I managed to get location, while on other system versions I always get location, null haven't appeared even once. That happens in every test condition I'm preparing and both on the real devices and on emulators.

I know how the getLastKnownLocation works, I'm checking if the provider is enabled, I'm requesting location updates and I'm using corret permissions in manifest.

I think there is something wrong with that exact system version. Is anyone capable of confirming my thoughts on the topic? Is there a bug in location obtaining on Android 2.3.3?


Solution

  • getLastKnownLocation can return null if there is no previous location. If that is the case, you need to wait for the value in onLocationChanged with the listener you registered.

    Note that GPS doesn't work in big cities, inside buildings etc.. Also some devices have additional location retrieving mechanisms such as A-GPS. So I guess it could also be a device specific problem.

    It is very very unlikely it is a problem with 2.3.3