草庐IT

nameValuePairs

全部标签

android - 使用 Http Post 发送图像

我想使用HttpPost将图像从android客户端发送到Django服务器。图片是从图库中选择的。目前,我正在使用列表值名称Pairs将必要的数据发送到服务器并以JSON格式接收来自Django的响应。可以对图像使用相同的方法(在JSON响应中嵌入图像的url)吗?另外,哪种方法更好:远程访问图像而不从服务器下载它们或将它们下载并存储在位图数组中并在本地使用它们?图片数量少(任何解决这些问题的教程将不胜感激。编辑:从图库中选择的图像在缩放到所需大小后发送到服务器。 最佳答案 我假设您知道要上传的图片的路径和文件名。使用image作

java - 使用 Gson 时出现奇怪的 "nameValuePairs"键

我正在尝试从其字段重建一个Object(我将字段作为JSONObject获取),如下所示:JSONObjectjObj=newJSONObject();JSONObjectjObj1=newJSONObject();JSONObjectjObj2=newJSONObject();JSONObjectjObj21=newJSONObject();JSONObjectjObj22=newJSONObject();jObj1.put("jObj11","value11");jObj1.put("jObj12","value12");jObj21.put("jObj211","value211

android - Intent putExtra ArrayList<NameValuePair>

有谁知道如何添加ArrayList将Intent作为额外的?ArrayListnameValuePairs=newArrayList();nameValuePairs.add(newBasicNameValuePair("first_name",first_name));nameValuePairs.add(newBasicNameValuePair("last_name",last_name));nameValuePairs.add(newBasicNameValuePair("email",email));nameValuePairs.add(newBasicNameValuePa

java - 无法解析符号 NameValuePair

在我的项目中出现错误:Errorretrievingparentforitem:Noresourcefoundthatmatchesthegivenname'android:TextAppearance.Material.Widget.Button.Inverse'.然后我尝试使用这个来修复它:compileSdkVersion23然后我得到了错误:cannotresolvesymbolNameValuePairandroid如何解决这个错误? 最佳答案 如果您想在具有最新API级别的androidstudio中使用NameValu

java - 不推荐使用 OpenConnection 的 NameValuePair

我一直在关注有关如何将数据从android应用程序插入到数据库中的在线教程,并且除了这个小部分之外,一切正常Listparams=newArrayList();params.add(newBasicNameValuePair("username",username));params.add(newBasicNameValuePair("password",password));NameValuePair和BasicNameValuePair已被弃用,取而代之的是openConnection()。我怎样才能创建一个新的值(value)关联呢?http://developer.androi

android - 如何使用 POST 使用 NameValuePair 将参数添加到 HttpURLConnection

我正在尝试使用HttpURLConnection进行POST(我需要这样使用它,不能使用HttpPost)并且我'想为该连接添加参数,例如post.setEntity(newUrlEncodedFormEntity(nvp));在哪里nvp=newArrayList();存储了一些数据。我找不到如何将这个ArrayList添加到我的HttpURLConnection中的方法:HttpsURLConnectionhttps=(HttpsURLConnection)url.openConnection();https.setHostnameVerifier(DO_NOT_VERIFY);h

android - 如何从 JSONObject 中删除 nameValuePairs 键?

我正在开发一个Android项目,该项目需要一个JSONObject作为我的POST请求的正文。放置JSON的键和值后,我得到以下行:{"xxxx":"zzzzzzz","yyyy":"uuuuuuu"}但是服务器得到了以下信息:{"name_value_pairs":{"xxxx":"zzzzzzz","yyyy":"uuuuuuu"}}我已经尝试过JSONStringer,但它并没有真正的帮助,因为请求的Content-Type是application/json。更新我没有尝试构造JSONObject,因为它已经通过使用以下代码行完成(@osayilgan给出的相同):JSONOb