I need a simple java example of processing a JSON response via HTTP for Android App?

前端 未结 3 1531
逝去的感伤
逝去的感伤 2021-01-16 05:15

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

相关标签:
3条回答
  • 2021-01-16 05:46

    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.

    0 讨论(0)
  • 2021-01-16 06:07

    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.

    0 讨论(0)
  • 2021-01-16 06:08

    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.

    0 讨论(0)
提交回复
热议问题