This week's book giveaway is in the Java in General forum.
We're giving away four copies of Java by Comparison (eBook) and have Simon Harrer, Jörg Lenhard, Linus Dietz on-line!
See this thread for details.
Win a copy of Java by Comparison (eBook) this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Using LocationManager and locationListener  RSS feed

Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm writing an app that finding a route from user location to a selected destination.
The general idea is to pick a destination point on the map and user location from GPS or phone tower
and then call Google routing web service.

The question is how should I get user location?
I can call LocationManager.requestLocationUpdates() and start looking for location updates.
but for how long? all I need is one starting point. nothing more. should I stop the listener at the first time
onLocationUpdate() is called? what is the common practice in this situation?

The second option is calling getLastKnownLocation(). how much can I relay on it?
right now I'm using only android emulator. don't have an acctual device to test this app yet.
I tried to connect to the running emulator using telnet and use geo fix to set locations. but then I noticed that calling getLastKnownLocation will not always return the last fix I entered. I'm probably doing something wrong. can you guide me here?

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!