How i can get the latitude and longitude of the current location, from android?
A:
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 indept discussion --
Umesh
2010-10-05 10:33:21
Getting null pointer Exception while use location.getLatitude();location.getLoongitude();
mohammedsuhail
2010-10-05 10:44:32
you probably haven't pushed the lat and long from DDMS. anyway can you post your code.
Umesh
2010-10-05 10:56:40
+1
A:
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
2010-10-05 10:47:49
+1. In fact I'm voting to close this question because it is an exact duplicate of that other question.
MarkJ
2010-10-05 13:10:45