Shiva
Shiva

Reputation: 31

Displaying current location in android

How to display current location with out using onLocationChanged method

Upvotes: 0

Views: 539

Answers (2)

Nicholas
Nicholas

Reputation: 7521

Use requestLocationUpdates() and when you reach onLocationChange, stop it. That what my program does, this way you ensure that once the new location is gotten it will stop looking for updates.

Upvotes: 0

Dan Lew
Dan Lew

Reputation: 87440

You could use LocationManager.getLastKnownLocation(), but that will only give you the last known location - which might be nothing (if the user just turned the phone on), or someplace hundreds of miles away (if the last time they turned a location service on was far away).

If you really want to know where the user is right now, you're going to have to implement a LocationListener.

Upvotes: 4

Related Questions