【问题标题】:Send LatLong to Server发送 LatLong 到服务器
【发布时间】:2012-05-08 20:44:23
【问题描述】:

我创建了一个 Lat-Long 应用程序,它需要将接收到的 Lat-Long 发送到服务器并将其存储在我的数据库中。请建议我如何将经纬度发送到服务器。

【问题讨论】:

    标签: android ip-address


    【解决方案1】:

    如果你使用 MySQL,你可以使用 php 脚本接收 lat 和 long 作为参数并将它们解析为查询..

    ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("lat", lat));
    nameValuePairs.add(new BasicNameValuePair("lng", lng));
    
    try {
                HttpClient httpClient = new DefaultHttpClient();
                HttpPost httpPost = new HttpPost("http://yourserver.com/script.php");
                httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                HttpResponse response = httpClient.execute(httpPost);
                HttpEntity entity = response.getEntity();
                is = entity.getContent();               
            }catch (Exception e) {
                // TODO: handle exception
                Log.e("log_tag", e.toString());
                return false;
                //Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-01
      • 2016-10-15
      • 1970-01-01
      • 2017-02-24
      • 2013-12-27
      • 2010-12-12
      • 2014-02-24
      • 2013-06-05
      相关资源
      最近更新 更多