i make a application for track geo location and save that data to server mysql database. when i run the application is it show unexpected error and close application. some times geolocation is not pointing. but when i comment that save code geo location tracking working nicely. cant find what is the exact problem in this here my code
///////////////// this is the updated locations/////////////
public void onLocationChanged(Location location) {
String msg = "Updated Location: " +
Double.toString(location.getLatitude()) + "," +
Double.toString(location.getLongitude());
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
loadSave();
// Report to the UI that the location was updated
}
public void loadSave() {
String mydataurl = "http://myrul.com/saveData.php";
//String type = params[0];
try {
String longi = "aaa"; // Double.toString(location.getLongitude());
String lati = "aare";//Double.toString(location.getLatitude());
String user = "a";
String code = "b";
String date = "c";
URL url = new URL(mydataurl);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
OutputStream outputStream = httpURLConnection.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
String post_data = URLEncoder.encode("longi", "UTF-8") + "=" + URLEncoder.encode(longi, "UTF-8") + "&" +
URLEncoder.encode("lati", "UTF-8") + "=" + URLEncoder.encode(lati, "UTF-8") + "&" +
URLEncoder.encode("user", "UTF-8") + "=" + URLEncoder.encode(user, "UTF-8") + "&" +
URLEncoder.encode("code", "UTF-8") + "=" + URLEncoder.encode(code, "UTF-8") + "&" +
URLEncoder.encode("date", "UTF-8") + "=" + URLEncoder.encode(date, "UTF-8");
bufferedWriter.write(mydataurl);
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
} catch (MalformedInputException e) {
e.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
}
STACK TRACE