I want to return the value of latitude and longitude into my EditText
s, I ve been able to do it using a Toast
but not achieved it through the EditText
. Kindly help
// EditText latEditText = (EditText)findViewById(R.id.lat);
//EditText lngEditText = (EditText)findViewById(R.id.lng);
protected void showCurrentLocation(){
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null){
String message = String.format(
"Current Location \n Longitude: %1$s \n Latitude: %2$s",
location.getLongitude(), location.getLatitude()
);
Toast.makeText(LayActivity.this, message,
Toast.LENGTH_LONG).show();
//latEditText.setText(nf.format(location.getLatitude()).toString());
//lngEditText.setText(nf.format(location.getLongitude()).toString());
}
}
private class MyLocationListener implements LocationListener{
@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
String message = String.format(
"New Location \n Longitude: %1$s \n Latitude: %2$s",
location.getLongitude(), location.getLatitude()
);
Toast.makeText(LayActivity.this, message, Toast.LENGTH_LONG).show();
//latEditText.setText((int) location.getLatitude());
//lngEditText.setText((int) location.getLongitude());
}