我正在尝试在我的php服务器中发送数据,但数据是纬度和经度格式。
这是错误:Error parsing data org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
private class sendlocation extends AsyncTask<String,String,String>
{
@Override
protected String doInBackground(String... args0)
{
double latlat = gps.getLatitude();
double longlong = gps.getLongitude();
String resultlat = Double.toString(latlat);
String resultlong = Double.toString(longlong);
List<NameValuePair> params = new ArrayList<NameValuePair>(2);
params.add(new BasicNameValuePair("Latitude",resultlat));
params.add(new BasicNameValuePair("Longitude",resultlong));
JSONObject json = jsonParser.makeHttpRequest(url_send_loc,"POST", params);
Log.d("Create Response", json.toString());
try
{
int success = json.getInt(TAG_SUCCESS);
if(success == 1)
{
Toast.makeText(getApplicationContext(),"Location Successfully sent: \nLat "+resultlat+" nLong" + resultlong ,Toast.LENGTH_LONG).show();
}
else
{ pdialog.dismiss();
Toast.makeText(getApplicationContext(), "Unknown error! Location not sent", Toast.LENGTH_LONG).show();
}
}catch(JSONException e)
{
e.printStackTrace();
}
return null;
};
}