Varand Pezeshkian
Varand Pezeshkian

Reputation: 520

location is null - is it the same behavior in real device?

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?

Upvotes: 0

Views: 829

Answers (1)

Falmarri
Falmarri

Reputation: 48567

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.

Upvotes: 1

Related Questions