I have a Geocoder and it works when I put a longitude and latitude in programically but when I try to put in the latitude and longitude from user location it force closes this is what I have
public String address(){
Geocoder gc = new Geocoder(this);
List<Address> list = null;
try {
list = gc.getFromLocation(latt(),longg(),1);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Address address = list.get(0);
StringBuffer str = new StringBuffer();
str.append("" + address.getLocality() + "\n");
str.append("" + address.getSubAdminArea() + "\n");
str.append("" + address.getAdminArea() + "\n");
str.append("" + address.getCountryName() + "\n");
str.append("" + address.getCountryCode() + "\n");
String strAddress = str.toString();
return strAddress;
}
public double latt(){
return LocationManagerHelper.getLatitude() ;
}
public double longg(){
return LocationManagerHelper.getLongitude();
}
Logcat
10-26 20:15:11.936: E/AndroidRuntime(28800): at http.www.hotapp.com.timeandlocation.TimeAndLocationActivity.address(TimeAndLocationActivity.java:95)
line 95 is Address address = list.get(0);
any suggestions on what i am doing wrong?
Later Question
My thoughts are that the numbers of the latitude and longitude are to long when they get pulled in. So my question is, is there anyway to make it so that the long and lat come in as a smaller digit? When I programicaly put in the long and lat its a shorter number latitude: 43.47389
Longitude:-114.34639
. When it is pulling from user location i get Latitude: 43.53400643333333
longitude: -114.32474341666666
. Even though When I put in the longer digits programically it still works fine.