本文介绍了发送的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("yourserver/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到服务器
发布评论