I have been unable to test my code on an emulator as Ive come to understand you cannot use geolocate on an emulator. Thus I'm not sure if Im initializing / using the functions utilities properly.
(I want to geolocate my phone, and print via a TextView
the closest known address to my lat/lon fix)
Heres my code:
Location location;
Geocoder geocoder;
TextView Address;
private OnClickListener OnClick = new OnClickListener(){
public void onClick (View src){
double latitude = location.getLatitude();
double longitude = location.getLongitude();
if (longitude != 0 && latitude != 0){
try {
List<Address> list = geocoder.getFromLocation(latitude, longitude, 1);
Address address = list.get(0);
StringBuilder sb = new StringBuilder();
sb.append(address);
String addressString = sb.toString();
Address.setText(addressString);
} catch (IOException e) {}
}
}
};