2012-04-22 29 views
1

我试图通过http请求发送GPS数据。Android SDK。 HTTP POST双变量

的问题是,GPS数据是双格式和nameValuePair.add(new BasicNameValuePair(String, String)

不会允许双重价值。

如何发送double值或将double转换为字符串?

感谢,

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

回答

1

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

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

我不能用'的toString()'函数,因为一颗灵长类动物的double类型的。我可以直接通过获取请求发送双倍数据吗? get url应该能够直接保存连接的变量。 – 2012-04-22 13:03:47

+0

对不起,我的错误,你可能会使用Double.toString(值),我会编辑答案来反映这一点。 – lenik 2012-04-22 13:17:19

+0

那么简单... – 2012-04-22 14:04:17