【发布时间】:2012-10-11 00:24:50
【问题描述】:
我已经阅读了很多教程,但仍然不清楚它是如何工作的。这是服务器端代码:
@GET
@Produces(MediaType.APPLICATION_JSON)
public JSONObject respondAsReady() throws JSONException {
JSONObject json = new JSONObject();
json.put("email", "email");
json.put("szam", 5);
json.put("boolean", true);
return json;
}
服务器端代码:
public class GetJson extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.getjson_layout);
Button get=(Button)findViewById(R.id.get);
get.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
getMethod();
}
});
}}
编写 getMethod 函数最简单的方法是什么?我不需要 AsyncTask,也不需要任何额外的东西,只是为了通过服务器取回用 @GET 编写的 JSONObject 例如,打印到控制台。
【问题讨论】:
标签: android json jersey httpclient http-get