title: How to do multiple API requests with Android-Async-Http?
body: <p>in my app i have to call an API for about 20 times after an the activity starts. There is no posibility to get all the data in one call. </p>
  
  <p>At the moment im using Android-Async-Http for only one call like this and it works well:</p>
  
  <pre><code>client = new AsyncHttpClient();
          client.get(DetailsActivity.this, url, new AsyncHttpResponseHandler() {
  
              @Override
              public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
  //working with the data
              }
  
              @Override
              public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
  
              }
          });
  </code></pre>
  
  <p>But what is the best way to do multiple calls against an API?</p>
  
  <p>Ok, this is the way im doing it now:</p>
  
  <pre><code>protected String doInBackground(String... params) {
  
           URL url;
           BufferedReader reader = null;
           String s = "";
           try {
               url = new URL(params[0]);
               URLConnection con = url.openConnection();
               reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
               String line = null;
               while ((line = reader.readLine()) != null) {
                   s = s + line;
               }
           } catch (MalformedURLException e) {
               e.printStackTrace();
           } catch (IOException e) {
               e.printStackTrace();
           }  catch (Exception e) {
               e.printStackTrace();
           } finally {
               if (reader != null) {
                   try {
                       reader.close();
                   } catch (IOException e) {
                       e.printStackTrace();
                   }
               }
           }
           Log.i(null, "response: " + s);
           return s;
       }
  </code></pre>
  
  <p>this allows me to start a lot of requests at the same time.</p>
  
  <p>Thanks in advance</p>
  
  <p>Michael</p>