问题
Hey guys as far as i don't have real android phone I wanted to ask this question. in my MapActivity which is extended from LocationListener, the onCreate method initializes "location" element as following :
location = locationManager.getLastKnownLocation(provider);
When I start my app, the location is always null until I send points from DDMS. I wanted to know, in real device what would be the behavior?
回答1:
getLastKnownLocation() only gets the location last returned by the GPS. If the gps has never gotten a location fix, it will be null. You can't count on this method returning a value at all, and if it does it might be extremely out of date.
If you want to get the actual location, you need to set up a locationlistener.
来源:https://stackoverflow.com/questions/4474470/location-is-null-is-it-the-same-behavior-in-real-device