Google からデータをダウンロードし、モノドロイド アプリケーションで場所のキーワード lat lng を取得するために、以下のコードを使用しています。
public LatLng GetLatLng (String input)
{
HttpURLConnection conn = null;
StringBuilder jsonResults = new StringBuilder ();
LatLng gp = null;
string str = null;
try {
StringBuilder sb = new StringBuilder (GEOCODER_API_BASE + OUT_JSON);
sb.Append ("?address=" + input + "&sensor=true");
/// "http://maps.googleapis.com/maps/api/geocode/json?address=Paris&sensor=true"
URL url = new URL (sb.ToString ());
conn = (HttpURLConnection)url.OpenConnection ();
Java.IO.InputStreamReader inp = new Java.IO.InputStreamReader (conn.InputStream);
// Load the results into a StringBuilder
int read;
char[] buff = new char[1024];
while ((read = inp.Read (buff)) != -1) {
jsonResults.Append (buff, 0, read);
}
str = jsonResults .ToString();
} catch (System.IO.IOException e) {
RltLog .HandleException (e, "\nError connecting to Places API\n");
return gp;
} finally {
if (conn != null) {
conn.Disconnect ();
}
}
try {
// Create a JSON object hierarchy from the results
JObject address = JObject .Parse (str);
JArray ja = (JArray)address ["results"];
JObject LocationJObejct = (JObject)ja [0] ["geometry"] ["location"];
gp = HelperMethods .executeLocationPoint (LocationJObejct ["lat"].ToString (),
LocationJObejct ["lng"].ToString ());
} catch (Exception e) {
RltLog .HandleException (e);
}
return gp;
}
しかし、私はこれらのエラーが発生し続けます:
Exception of type 'Java.IO.FileNotFoundException' was thrown.
理由は何だろう?