android - 如何获取默认内容类型 Android Volley

标签 android http-headers android-volley

我想知道如何从 volley android 中的标题获取默认内容类型

      @Override
        public Map<String, String> getHeaders() throws AuthFailureError {

            Map<String, String> headers = new HashMap<String, String>();
            headers.put("Authkey", Agent_Name);
            headers.put("apptype", "android");
            headers.put("apptoken", gcmID);
            return headers;
        }

这里我没有提到内容类型,所以如何获取默认内容类型。

最佳答案

   I just append text fields to the body and created the following function to do it in multipart :

  private void buildTextPart(DataOutputStream dataOutputStream, String 
parameterName, String parameterValue) throws IOException {

    dataOutputStream.writeBytes(twoHyphens + boundary + lineEnd);
    dataOutputStream.writeBytes("Content-Disposition: form-data; name=\"");
    dataOutputStream.write(parameterName.getBytes("UTF-8"));
    dataOutputStream.writeBytes(lineEnd);
    dataOutputStream.writeBytes("Content-Type: text/plain; charset=UTF-8" + 
  lineEnd);
    dataOutputStream.writeBytes(lineEnd);
    dataOutputStream.write(parameterValue.getBytes("UTF-8"));
    dataOutputStream.writeBytes(lineEnd)

 }

 here mention multipart data format ,and text format as utf8,its working fine

关于android - 如何获取默认内容类型 Android Volley ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47654996/

相关文章:

Android画中画模式,打开我的应用程序的另一个 Activity

http - 使用 "Content-Encoding":"GZIP"

http - "Cache request directives"和 "Cache response directives"都需要吗?

java - 在 Activity 之间导航时如何保留数据而不加载数据

android - Gradle在maven上找不到volley

android - Volley 的 NetworkImageView 中的模糊图像

android - 在 Android 上安装/更新 cordova 应用程序时出现错误 -505

Android Auto - 语音 - 无法执行 "Play [x] on [y]"

java - Android contentprovider 不返回 Phone.NUMBER

csv - 我应该为 CSV 使用什么 MIME 类型?