1

I am writing a simple Android app and have a database that will send back information into the app. I am new to Android and am looking for a simple example that demonstrates how the Android App can process a JSON response received from a HTTP request.

I need to see what classes are used for Android apps to process a HTTP response. A reference to a good tutorial, or if you're keen, write a very basic method to do the job. Thanks

angryITguy
  • 9,027
  • 8
  • 54
  • 80

3 Answers3

3

Take a look to: JSON Parsing in android or Android as a RESTful Client.

Also read Handling Expensive Operations in the UI Thread to be sure that your application is not "hanging" if content retrieval takes time.

Laimoncijus
  • 8,355
  • 10
  • 57
  • 80
  • Those 2 links were really helpful. Seems to cover the topic enough for me. So you get the "correcta-mundo". Thanks!!! – angryITguy Aug 29 '10 at 23:42
2

I once wrote a tutorial for the exact opposite case (to send a JSON request). However from that you will be able to derive for what you need.

znq
  • 43,855
  • 39
  • 115
  • 144
  • Thanks for submitting your tutorial. I'll have a look at it and try it out. I need to support XML and JSON. – angryITguy Apr 12 '11 at 23:24
0

I wrote a small library project (stepsdk) and demo here, on making a GET request and process the json here.

It is as simple as follows:

new APIRequest(new APIManager(this), SERVER_URL+"/method", APIRequest.GET)
  .addParam('param', 'value')
  .start(new JSONRequestHandler(){
      @Override
      public void after() {
        JSONObject json = getResponse();
        // use json
      }
  });

hope it helps.

alvinsj
  • 865
  • 11
  • 15