I am trying to get the user’s current latitude/longitude, using the following code :
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location location = (Location) lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
double longitude = location.getLongitude();
double latitude = location.getLatitude();
I keep getting the error that the methods getLatitude()/getLongitude() are undefined for the type Location.
How can I resolve this ? Thanks in advance.
add these two imports or if you are using eclipse simply press ctrl+shift+O and try