我有这个代码:
package sig;
import org.json.JSONObject;
public class MyService extends java.lang.Object{
public JSONObject getLocationInfo( double lat, double lng) {
HttpGet httpGet = new HTTP("http://maps.google.com/maps/api/geocode/json?latlng="+lat+","+lng+"&sensor=false");
HttpClient client = new DefaultHttpClient();
HttpResponse response;
StringBuilder stringBuilder = new StringBuilder();
try {
response = client.execute(httpGet);
HttpEntity entity = response.getEntity();
InputStream stream = entity.getContent();
int b;
while ((b = stream.read()) != -1) {
stringBuilder.append((char) b);
}
} catch (ClientProtocolException e) {
} catch (IOException e) {
}
JSONObject jsonObject = new JSONObject();
try {
jsonObject = new JSONObject(stringBuilder.toString());
} catch (JSONException e) {
e.printStackTrace();
}
return jsonObject;
}
}
但它错误HttpGet
,我应该使用什么库才能使用HttpGet
,谢谢!