我如何通过 JAVA (android) 发送请求并接收响应 (JSON)?

How can i send the request and receive the response (JSON ) via JAVA (android)?

如何在 java(android) 中发送 http 请求并解析 JSON 格式的响应。我知道这很简单,但我是 Java (android) 的新手。

您似乎想要向提供的 url 发送一个简单的 http get 请求。 发送一个简单的 GET 请求:

  1. 创建HttpClient对象

HttpClient client = new DefaultHttpClient();

  1. 创建 HttpGet 对象

HttpGet request = new HttpGet("http://www.example.com");

  1. 向服务器端发起请求

HttpResponse response;

try {
response = client.execute(request);

    Log.d("Response of GET request", response.toString());
} catch (ClientProtocolException e) {
    // TODO Auto-generated catch block
        e.printStackTrace();
} catch (IOException e) {
      // TODO Auto-generated catch block
     e.printStackTrace();
}

然后根据您的响应格式,您要解析它。 也不要忘记在您的 manifest.xml 文件中包含必要的权限,例如使用互联网的权限。

你也可以查看 volley:

http://developer.android.com/training/volley/index.html