【发布时间】:2016-02-10 19:10:55
【问题描述】:
我想在我的应用程序中循环发送纬度和经度。 这是使用 GPS 获取此参数的函数
private void showLocation(Location location) {
String latitude = "Latitude: ";
String longitude = "Longitude: ";
if (location != null) {
latitude += location.getLatitude();
longitude += location.getLongitude();
}
}
我在网上寻找方法,我找到了一些方法,但没有用,已弃用
public void sendData(double latitude, double longitude){
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://192.x.x.x:8080/run/mypage.php");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("Latitude", Double.toString(latitude)));
nameValuePairs.add(new BasicNameValuePair("Longitude", Double.toString(longitude)));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
【问题讨论】:
-
获取位置或将其发布到服务器有问题吗?
-
发布到服务器
标签: java android geolocation