0
我已經得到了我需要的座標和其他參數。我用這張貼到我的服務器:我如何在服務器上訪問(請參閱)我從Android發送到服務器的GPS座標?
String postData = "{\"request\":{\"type\":\"locationinfo\"},\"userinfo\":{\"latitude\":\""+latitude+"\",\"longitude\":\""+longitude+"\",\"speed\":\""+speed+"\"}}";
HttpClient httpClient = new DefaultHttpClient();
// Post method to send data to server
HttpPost post = new HttpPost();
try {
post.setURI(new URI("http://10.0.2.15:80"));
} catch (URISyntaxException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// set your post data inside post method
try {
post.setEntity(new StringEntity(postData));
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// execute post request here
try {
HttpResponse response = httpClient.execute(post);
} catch (ClientProtocolException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
我怎麼確定它已經到服務器?我如何看到服務器上的座標? 我想將這些值保存在數據庫中並處理它們。
但我如何確認它已經到服務器? – user1698122 2013-04-28 14:53:55
據我所知,你想知道服務器是否從客戶端獲取數據,對嗎?如果是這樣,只要發回你收到的東西!可能是我誤會了。你可以寫更多的細節或舉例。 – 2013-04-28 15:06:56