I want to send latitude and longitude cyclically in my app. This is the function which get this parameters using GPS
private void showLocation(Location location) {
String latitude = "Latitude: ";
String longitude = "Longitude: ";
if (location != null) {
latitude += location.getLatitude();
longitude += location.getLongitude();
}
}
I was looking methods in the web, I found some but it didn't work and it's deprecated
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
}
}