Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Http获取请求Android_Android_Web Services_Http_Rest - Fatal编程技术网

Http获取请求Android

Http获取请求Android,android,web-services,http,rest,Android,Web Services,Http,Rest,我知道可以将一些数据放入GET请求正文,但我知道这不是一个好做法 虽然我想做,但我不知道怎么做。我在网上搜索了一下,但什么也没找到 你能给我一些小的代码示例或参考我一些有用的信息吗 假设我们有此代码,如何将nameValuePairs添加到GET request的request body: String url = "something"; HttpClient httpClient = new DefaultHttpClient(); HttpC

我知道可以将一些数据放入
GET
请求正文
,但我知道这不是一个好做法

虽然我想做,但我不知道怎么做。我在网上搜索了一下,但什么也没找到

你能给我一些小的代码示例或参考我一些有用的信息吗

假设我们有此代码,如何将
nameValuePairs
添加到
GET request
request body

        String url = "something";
        HttpClient httpClient = new DefaultHttpClient();
        HttpConnectionParams.setConnectionTimeout(httpClient.getParams(),
                TIMEOUT_MS);
        HttpConnectionParams.setSoTimeout(httpClient.getParams(), TIMEOUT_MS);
        HttpGet httpGet = new HttpGet(url);
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();

        nameValuePairs.add(new BasicNameValuePair("dtype", "0"));
        nameValuePairs.add(new BasicNameValuePair("category_id", ""));

        HttpResponse response = httpClient.execute(httpGet);
        System.out.println("log in");
stringurl=“某物”;
HttpClient HttpClient=新的DefaultHttpClient();
HttpConnectionParams.setConnectionTimeout(httpClient.getParams(),
超时(毫秒);
HttpConnectionParams.setSoTimeout(httpClient.getParams(),超时);
HttpGet HttpGet=新的HttpGet(url);
List nameValuePairs=新的ArrayList();
添加(新的BasicNameValuePair(“数据类型”,“0”));
添加(新的BasicNameValuePair(“类别id”);
HttpResponse response=httpClient.execute(httpGet);
System.out.println(“登录”);

提前感谢。

您需要使用HttpPost类而不是HttpGet。我知道,但现在我想使用GET。