i need to send data on url onLocationChanges method,m trying to accomplish the task with following code,but m getting error,can someone help me out? My program crash with following code
@Override
public void onLocationChanged(Location location) throws NetworkOnMainThreadException {
txtLat = (TextView) findViewById(R.id.address_textview);
txtLat.setText("Latitude:" + location.getLatitude() + ", Longitude:" + location.getLongitude());
String strUrl="http://www.test.com/location.php?location="+location.getLatitude();
try {
url = new URL(strUrl);
} catch (MalformedURLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.connect();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}