I tried to get an answer from server and conver it to JSONObject.
At Now I have this code
private JSONObject sendData(ArrayList<NameValuePair> data, String actionname)
{
// 1) Connect via HTTP. 2) Encode data. 3) Send data.
try
{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new
HttpPost(actionname);
httppost.setEntity(new UrlEncodedFormEntity(data));
HttpResponse response = httpclient.execute(httppost);
// Log.i("postData", response.getStatusLine().toString());
InputStream is = response.getEntity().getContent();
String result = convertStreamToString(is);
// JSONArray jArr = new JSONArray (result);
// int eventID = jArr.getJSONObject(0).getInt("eventID");
JSONObject jObject = new JSONObject(result);
return jObject;
}
catch(Exception e)
{
Log.e("log_tag", "Error: "+e.toString());
}
return null;
}
in result string variable I have this
{"status":{"code":404,"text":"Not Found"},"content":"User authentication failure"}
But on the string of code JSONObject jObject = new JSONObject(result); - It go to the return null; =(( I tried to create JSONArray but it return me an extention that I can create JSONARRAY from JSONObject.