tags:

views:

63

answers:

2

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 --

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

Umesh
Getting null pointer Exception while use location.getLatitude();location.getLoongitude();
mohammedsuhail
you probably haven't pushed the lat and long from DDMS. anyway can you post your code.
Umesh
+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
+1. In fact I'm voting to close this question because it is an exact duplicate of that other question.
MarkJ