I am getting one id of some event from the previous activity to this activity and passing this id to the url in current activity to get cityname present in that url. My code is..
String s = getIntent().getStringExtra("ar");
try{
HttpPost hpost = new HttpPost("xxxxxxxxxxxxxxxxx/id");
HttpResponse response = login.client.execute(hpost);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("id", s));
hpost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
String re = EntityUtils.toString(response.getEntity());
System.out.print(re);
JSONObject root = new JSONObject(re);
eveState.setText(root.getString("cityname"));
}
catch(Exception e){
Log.e("exvcx", "error getting data" +e.toString());
}
The exception I am getting is that no value for cityname
. I think I am unable to pass the id to this url..Please tell is this the right method? If yes please provide solution to the problem otherwise please correct me where I am doing wrong. Thanks.
{"status":1,"response":[{"id":"73","name":"Dangerous","address":"Rydgggh","location":"Entry try","phnumber":"2467568","createdate":"2012-07-11 06:24:31","image":"4ffd626f021487.45227344.jpg","block":"n","deleted":"n","cityname":"Juneau","statename":"Alaska","interestname":"Comedy","username":"princeb","eventdate":"2012-07-13 15:45:29","formatteddate":"July 13, 2012"}],"imageWidth":1024,"imageHeight":1024}