ソース1
package cafe.hawaii;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
import android.content.Context;
import android.location.Address;
import android.location.Geocoder;
import android.util.Log;
public class ReverseGeocode {
final String tag = "ReverseGeocode";
public String point2address(double latitude, double longitude, Context context) throws IOException{
String string = new String();
Log.d(tag, "Start point2adress");
Geocoder geocoder = new Geocoder(context, Locale.JAPAN);
List<Address> list_address = geocoder.getFromLocation(latitude, longitude, 5);
if (!list_address.isEmpty()){
Address address = list_address.get(0);
StringBuffer strbuf = new StringBuffer();
String buf;
for (int i = 0; (buf = address.getAddressLine(i)) != null; i++){
Log.d(tag, "loop no."+i);
strbuf.append("address.getAddressLine("+i+"):"+buf+"\n");
}
string = strbuf.toString();
}
else {
Log.d(tag, "Fail Geocoding");
}
Log.d(tag, string);
return string;
}
}