发送的LatLong到服务器 [英] Send LatLong to Server

查看:130
本文介绍了发送的LatLong到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了需要发送接收到的纬度龙到服务器并将其存储在我的数据库纬度龙的应用程序。请建议我如何发送经纬度长到服务器。

I've created a Lat-Long application that needs to send the received Lat-Long to a server and store it in my database. Please suggest me how to send lat-long to server.

推荐答案

如果你正在使用MySQL,你可以使用接收lat和长为参数的PHP脚本,并将其解析到查询..

If you are using MySQL, you can use a php script which receive lat and long as parameters and parse them to the query..

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();
        }

这篇关于发送的LatLong到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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