2

I am developing an android app which requires to work on the user's current location. I am working on an emulator. So I send dummy co-ordinates to the emulator initially either through telnet or emulator control in Eclipse. After I send, the app displays the sent co-ordinates as current location in the emulator screen. But after that, how are the co-ordinates updated when we change the location? When does the onLocationChanged method get called? How do we get the updated current location?

ManJan
  • 3,939
  • 3
  • 20
  • 22
  • kindly refer this [link][1] [1]: http://stackoverflow.com/questions/5481695/how-to-enable-gps-in-android-coding – Triode Feb 16 '12 at 04:26
  • Try this tutorial might help you http://www.firstdroid.com/2010/04/29/android-development-using-gps-to-get-current-location-2/ http://marakana.com/s/tutorial_android_location_service_example,311/index.html – Avi Kumar Feb 16 '12 at 04:27

2 Answers2

2

how are the co-ordinates updated when we change the location?

Like you send the lat and long and you display the current location like wise if your location will change then it will also trigger same.

When does the onLocationChanged method get called?

When you get the new location then it will called onLocationChanged. There are certain criteria for get the new location other than the current location. Focus on the below method

public void requestLocationUpdates (String provider, long minTime, float minDistance, LocationListener listener)

In above method there are two parameters minTime and minDistance

minTime:: the minimum time interval for notifications, in milliseconds. This field is only used as a hint to conserve power, and actual time between location updates may be greater or lesser than this value.

minDistance :: the minimum distance interval for notifications, in meters

How do we get the updated current location?

When new location will found it will call the onLocationChanged() method

If you want to check for the new Location after first time sending the co-ordinate from the emulator control then again send the different co-ordinates so that it will call a method onLocationChanged().

Dharmendra
  • 33,296
  • 22
  • 86
  • 129
0

you have to use onlocationChange listener to listen for location changes.

Rakshi
  • 6,796
  • 3
  • 25
  • 46