Skip to content

Instantly share code, notes, and snippets.

@meeDamian
Last active November 15, 2015 20:03
Show Gist options
  • Save meeDamian/f4ddeacf76851341a2ae to your computer and use it in GitHub Desktop.
Save meeDamian/f4ddeacf76851341a2ae to your computer and use it in GitHub Desktop.
String locationQuery = null;
if (country != null)
locationQuery = country;
if (city != null) {
if (locationQuery == null)
locationQuery = city;
else
locationQuery += ", " + city;
}
if (locationQuery != null) {
try {
Address address = new Geocoder(MainActivity.this).getFromLocationName(locationQuery, 1).get(0);
Log.d("Basic Data", String.format("Lat: %f, Lng: %f", address.getLatitude(), address.getLongitude()));
} catch (IOException e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment