Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.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
Android 如何将编码设置为Http Post请求_Android_Character Encoding_Http Headers - Fatal编程技术网

Android 如何将编码设置为Http Post请求

Android 如何将编码设置为Http Post请求,android,character-encoding,http-headers,Android,Character Encoding,Http Headers,如何将UTF编码设置为httppost请求 这是我的代码片段 HttpClient httpClient = getNewHttpClient(); String user_agent = (String) httpClient.getParams().getParameter( CoreProtocolPNames.USER_AGENT) + " Android"; httpClient.getParams().setParam

如何将
UTF
编码设置为
httppost
请求

这是我的代码片段

HttpClient httpClient = getNewHttpClient();

    String user_agent = (String) httpClient.getParams().getParameter(
            CoreProtocolPNames.USER_AGENT)
            + " Android";
    httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT,
            user_agent);
    httpClient.getParams().setBooleanParameter(
            "http.protocol.expect-continue", false);
    HttpResponse response;
    HttpPost post = new HttpPost(remoteUrl);
    System.out.println("Url:" + remoteUrl + "  values:"
            + nameValuePair.toString());
    post.setEntity(new UrlEncodedFormEntity(nameValuePair));


    response = httpClient.execute(post);
    int postStatus = response.getStatusLine().getStatusCode();
    String result = EntityUtils.toString(response.getEntity());
    System.out.println("result:" + result);

您可以通过调用
post.setHeader(“标题名”、“标题值”)

你的情况应该是这样的


post.setHeader(“接受字符集”、“utf-8”)

它处理了这个请求;