2

How i can get the latitude and longitude of the current location, from android?

mohammedsuhail
  • 701
  • 2
  • 11
  • 23
  • 1
    possible duplicate of [What is the simplest and most robust way to get the user's current location in Android?](http://stackoverflow.com/questions/3145089/what-is-the-simplest-and-most-robust-way-to-get-the-users-current-location-in-an) – MarkJ Oct 05 '10 at 13:10
  • Here's your answer: http://stackoverflow.com/questions/3145089/what-is-the-simplest-and-most-robust-way-to-get-the-users-current-location-in-an/3145655#3145655 – Edi Oct 05 '10 at 10:47
  • +1. In fact I'm voting to close this question because it is an exact duplicate of that other question. – MarkJ Oct 05 '10 at 13:10
  • I wouldn't say it's an exact duplicate, because that question is asking how to get the location, this is asking for lat/long specifically. Granted, location gives the lat/long when you ask for it, but still. This is like another step that they don't cover. – Brandon Jan 28 '11 at 22:47

1 Answers1

3

you can use the LocationListener class to get the coordinates while on the move.

use the following to get the coordiates when not on the move.

LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);    
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);  

if(location == null){
    LAT = 0.0;
    LONG = 0.0;
    loc.setText("No Location");
}

for an indepth discussion --

http://www.devx.com/wireless/Article/39239/1954

Pacerier
  • 86,231
  • 106
  • 366
  • 634
Umesh
  • 4,406
  • 2
  • 25
  • 37