Possible Duplicate:
Example of how to download JSON from server?
I’ve read quite a few tutorials but it’s still not clear how it works. This is the server side code:
@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;
}
Server-side code:
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();
}
});
}}
What’s the easiest way to code the getMethod function? I don’t need neither AsyncTask, nor any extras, just to get back the JSONObject written in @GET through the server
For example, print to console.
How to consume a REST web service
String url = "getserviceurl";// such ashttp://yourhost:8080/rest-ws/resources/admin/getCities