-1

I am looking for something like following code. I know the code below is obviously wrong, I just want to make it clear that what I am looking for.

private HttpRequest httpRequest;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // instiantiate the httpRequest
        httpRequest = HttpRequest.init();

        httpRequest.get("http://www.example.com", HttpRequest.callbackFunction(){
            @Override
            public void Result(String err, String recv){
                // done something here 
            }
        });
    }

** Must works in background and implement with callback function

** It must be able to be called multiple times on single activity. AsyncTask is not the things I want.

** I don't mind open source library. As long as it achieved what I needs

edisonthk
  • 1,403
  • 16
  • 35
  • What's wrong with multiple AsyncTasks? – Ted Hopp Jul 21 '13 at 20:39
  • Volley from Google might be worth checking. Please look at this SO [thread for details][1] [1]: http://stackoverflow.com/questions/16659620/volley-android-networking-library – Lefteris Jul 21 '13 at 22:14

1 Answers1

1

UPDATE
This is and old question, Now we have many good Network libs for Android.
OkHttp, Retrofit, Ion, .....etc.


Two excellent libs I have used:
1- Android Query (AQuery)

aq.ajax(url, String.class, new AjaxCallback<String>() {
     @Override
     public void callback(String url, String html, AjaxStatus status) {

     }   
});

2- Android Asynchronous Http Client

AsyncHttpClient client = new AsyncHttpClient();
client.get("http://www.google.com", new AsyncHttpResponseHandler() {
    @Override
    public void onSuccess(String response) {

    }
});
JafarKhQ
  • 8,676
  • 3
  • 35
  • 45