我从上一个活动到此活动中获取某个事件的一个 id,并将此 id 传递给当前活动中的 url,以获取该 url 中存在的城市名称。我的代码是..
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());
}
我得到的例外是cityname
. 我想我无法将 id 传递给这个 url..请告诉这是正确的方法吗?如果是,请提供问题的解决方案,否则请纠正我做错的地方。谢谢。
{"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}