2013-04-27 58 views
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(); 
           } 

我怎么确定它已经到服务器?我如何看到服务器上的坐标? 我想将这些值保存在数据库中并处理它们。

回答

0

当服务器接收你的数据只是将它们保存在数据库中,并作为结果,一切都被保存,(通过服务器从客户端接受数据)返回相同的数据,您的客户端程序。

使用这种方法,你一定会在:

  1. 服务器接受您的数据
  2. 服务器接受正确的数据
  3. 服务器保存的数据

例:

假设我想向服务器发送'Name = Michael'参数。当服务器接受参数名称时,我将它保存在数据库中,并将相同的参数返回给客户端 - >'Name = Michael'。因此,您可以确保服务器获取参数。

+0

但我如何确认它已经到服务器? – user1698122 2013-04-28 14:53:55

+0

据我所知,你想知道服务器是否从客户端获取数据,对吗?如果是这样,只要发回你收到的东西!可能是我误会了。你可以写更多的细节或举例。 – 2013-04-28 15:06:56

相关问题