Question

I am new to LoopJ Android Asynchronous-Http-Client. I figured out how to use my web service to POST to the database but now I cannot figure out how to GET the data from the database with my PHP web service. I need to obtain all the information in an entire Table and I know that I need to parse the information once it is received. I have this for a POST:

    AsyncClient.CreatePost("create_entry.php", null, 
            new JsonHttpResponseHandler());

Is the GET similar to this?

        AsyncClient.GetPost("retrieve_entry.php", null, 
            new JsonHttpResponseHandler());

Once I GET the data where is the information stored so that I can display it to the user? I am lost. I have looked around and I can't seem to find the proper documentation. Help!

Was it helpful?

Solution

You can make a call to the HttpGet method from the loopj like this

AsyncHttpClient client = new AsyncHttpClient();
client.get("retrieve_entry.php",null, new JsonHttpResponseHandler() {
    @Override
    public void onSuccess(String response) {
       log.e("Response",response);
    }


   @Override
     public void onFailure(Throwable e, JSONArray errorResponse) {
     Log.e(TAG, "OnFailure!", e);
     }
});

OTHER TIPS

Look man after get this data you can cache it or simple display it, the callbacks are invoked on UI thread but the network is out of UI thread, I recommend use JSON to get the data and serialize into models using Jackson or Gson.

The information is not stored, it's in memory you need override one of the callbacks and get these results on onsuccess callback on AsyncHttpResponseHandler.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top