Android的SDK。 HTTP POST双变量 [英] Android SDK. HTTP POST double variable

查看:170
本文介绍了Android的SDK。 HTTP POST双变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过HTTP请求发送GPS数据。

问题是,GPS数据是双格式和 nameValuePair.add(新BasicNameValuePair(字符串,字符串)

将不允许双重价值。

我如何发送双重价值或转换双为字符串?

谢谢,

  HttpClient的客户端=新defaulthttpclient();
httppost后=新httppost(网址);
post.setEntity(新Urlen codedFormEntity(namevaluepairs中));
HTT presponse响应= client.execute(岗位);


解决方案

您可能需要使用两个namevaluepairs中单独发送经纬度:

 双纬度= currentLocation.getLatitude();
双经度= currentLocation.getLongitude();
nameValuePairs.add(新BasicNameValuePair(纬度,Double.toString(纬度)));
nameValuePairs.add(新BasicNameValuePair(经度,Double.toString(经度)));

I'm trying to send GPS data over http request.

The problem is that the GPS data is in double format and nameValuePair.add(new BasicNameValuePair(String, String)

will not allow double values.

How do I send double values or convert the double to a string?

Thanks,

httpclient client = new defaulthttpclient();
httppost post = new httppost("web address");
post.setEntity(new UrlencodedFormEntity(nameValuePairs));
httpresponse response = client.execute(post);

解决方案

you may need to use two nameValuePairs to send latitude and longitude separately:

double latitude = currentLocation.getLatitude();
double longitude = currentLocation.getLongitude();
nameValuePairs.add(new BasicNameValuePair("latitude",Double.toString(latitude)));
nameValuePairs.add(new BasicNameValuePair("longitude",Double.toString(longitude)));

这篇关于Android的SDK。 HTTP POST双变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆