-2

Actually I want to calculate distance between two user's coordinates. Is there anywhere that would be a good place for me to start with GPS feature on Android, or that has a good example of how to use GPS?

I don't want anything deep, literally just how to retrieve and use current GPS coordinates. I would like to start simple and build up from there.

swiftBoy
  • 35,607
  • 26
  • 136
  • 135
laksh
  • 1
  • 1

1 Answers1

0

To get latitude, please start here for reference:

https://developer.android.com/reference/android/location/Location.html#getLatitude()

Example code (not compiled or tested):

LocationManager locmgr=(LocationManager)ctx.getSystemService(Context.LOCATION_SERVICE);
Location l=locmgr.getLastKnownLocation(LocationManager.GPS_PROVIDER);
double latitude = l.getLatitude();
Kyle Sweet
  • 306
  • 1
  • 3
  • 15