アドレスをlongとlatに変換しようとしていますが、0が返されます。何が間違っているのか教えてください。これが私のコードです:
geocoder = new Geocoder(this);
buttonSave.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
EditText loc = (EditText)findViewById(R.id.txtAddress);
String locationName = loc.getText().toString();
List<Address> addressList = geocoder.getFromLocationName(locationName, 2);
if(addressList!=null && addressList.size()>0) {
lat = (int)(addressList.get(0).getLatitude()*1000000);
lng = (int)(addressList.get(0).getLongitude()*1000000);
}
} catch (IOException e) {
e.printStackTrace();
}
lattitude = Integer.toString(lat);
longertude = Integer.toString(lng);
私のLOGCAT:
07-03 13:44:28.799: I/System.out(274): [INFO:19529614]: LogSource: Running flush
07-03 13:44:28.799: I/System.out(274): [INFO:19529623]: LogSource: Sending payload [bytes=267]
07-03 13:44:32.262: D/SntpClient(83): request time failed: java.net.SocketException: Address family not supported by protocol
07-03 13:44:33.809: I/System.out(274): [INFO:19534623]: LogSource: Running delayed flush
07-03 13:44:33.809: W/System.err(2517): java.io.IOException: Unable to parse response from server
07-03 13:44:33.823: I/System.out(274): [INFO:19534640]: LogSource: Running flush
07-03 13:44:33.829: I/System.out(274): [INFO:19534651]: LogSource: Sending payload [bytes=267]
07-03 13:44:33.869: W/System.err(2517): at android.location.Geocoder.getFromLocationName(Geocoder.java:178)
07-03 13:44:33.869: W/System.err(2517): at de.vogella.android.locationapi.simple.InsertStock$1.onClick(InsertStock.java:108)
07-03 13:44:33.879: W/System.err(2517): at android.view.View.performClick(View.java:3110)
07-03 13:44:33.891: W/System.err(2517): at android.view.View$PerformClick.run(View.java:11928)
07-03 13:44:33.899: W/System.err(2517): at android.os.Handler.handleCallback(Handler.java:587)
07-03 13:44:33.899: W/System.err(2517): at android.os.Handler.dispatchMessage(Handler.java:92)
07-03 13:44:33.899: W/System.err(2517): at android.os.Looper.loop(Looper.java:132)
07-03 13:44:33.913: W/System.err(2517): at android.app.ActivityThread.main(ActivityThread.java:4025)
07-03 13:44:33.919: W/System.err(2517): at java.lang.reflect.Method.invokeNative(Native Method)
07-03 13:44:33.939: W/System.err(2517): at java.lang.reflect.Method.invoke(Method.java:491)
07-03 13:44:33.939: W/System.err(2517): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
07-03 13:44:33.939: W/System.err(2517): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
07-03 13:44:33.939: W/System.err(2517): at dalvik.system.NativeStart.main(Native Method)
しかし、エラーはありません(赤い言葉)