title: Fastest way to download a webpage in android?
body: <p>Main problem is that everything work fine. but it is not responsive. it take time to show results. How can i make it fast enough to get results faster.</p>
  
  <p>There are three AsyncTask in a single activity.. one for the autoTextview change. whenever user enter some text it calls the AsynTask function.   </p>
  
  <p>AutoTextView textChangeListener .. when user enter something it call it</p>
  
  <pre><code>textView.addTextChangedListener(new TextWatcher() {
  
              @Override
              public void onTextChanged(CharSequence cs, int arg1, int arg2,
                      int arg3) {
  
                  seq = cs;
  
              }
  
              @Override
              public void beforeTextChanged(CharSequence s, int arg1, int arg2,
                      int arg3)
              {
  
              }
  
              @Override
              public void afterTextChanged(Editable arg0)
              {
                  new SearchTask().execute(seq.toString().trim());
              }
          });
  </code></pre>
  
  <p>AsyncTask for autoTextview is</p>
  
  <pre><code>private class SearchTask extends AsyncTask&lt;CharSequence, Void, String&gt; 
      {
  
          ArrayAdapter&lt;String&gt; adapter;
  
          String[] array;
  
          @Override
          protected void onPreExecute() 
          {
              super.onPreExecute();
          }
  
          @Override
          protected String doInBackground(CharSequence... params) 
          {
              try {
                  HttpClient httpclient = new DefaultHttpClient();
  
                  HttpPost httppost = new HttpPost(pak_url + params[0]);
  
                  HttpResponse responce = httpclient.execute(httppost);
  
                  HttpEntity httpEntity = responce.getEntity();
  
                  String response = EntityUtils.toString(httpEntity);
  
                  Log.d("response is", response);
  
                  if (response != null) {
                      String substr = response.split("\\(")[2].split("\\)")[0];
  
                      array = substr.split(",");
  
                      for (int i = 0; i &lt; array.length; i++) {
  
                          array[i] = array[i].replace("'", "");
                      }
  
                  }
  
                  return response;
              } catch (Exception e) {
                  e.printStackTrace();
              }
  
              return null;
          }
  
          @Override
          protected void onPostExecute(String result) {
              super.onPostExecute(result);
  
              if (array != null) {
                  adapter = new ArrayAdapter&lt;String&gt;(PlayListActivity.this,
                          android.R.layout.simple_list_item_1, array);
  
                  textView.setAdapter(adapter);
  
                  adapter.getFilter().filter(seq);
              } 
  </code></pre>
  
  <p>Second AsyncTask to download Full webpage and Store it in String .. and when String is recieved . append autotextview text to it and call another AsyncTask .. Everything goes right . .but don't know why it is so slow .. Some one guide me how can i make it responsive. and fast..</p>
  
  <pre><code>class RetrieveFeedTask extends AsyncTask&lt;String, Void, String&gt; 
      {   
          @Override
          protected void onPreExecute() 
          {
              super.onPreExecute();
  
              Utilities.hideSoftKeyboard(PlayListActivity.this);
  
              progressDialog = ProgressDialog.show(PlayListActivity.this,
                      "Loading...", "Please wait...");
          }
  
          @Override
          protected String doInBackground(String... urls) {
              try {
                  URL url= new URL(urls[0]);
  
                  URLConnection conn = url.openConnection();
  
                  // open the stream and put it into BufferedReader
                  BufferedReader br = new BufferedReader(
                          new InputStreamReader(conn.getInputStream()));
  
                  String inputLine;
                  String HTML_response = "";  
                  while ((inputLine = br.readLine()) != null) {
                      // System.out.println(inputLine);
                      HTML_response += inputLine;
                  }
                  br.close();
  
                  System.out.println("Done");
  
                  return HTML_response;
              } /*catch (MalformedURLException e) {
                  e.printStackTrace();
              } catch (IOException e) {
                  e.printStackTrace();
              }*/catch (Exception e) {
                  e.printStackTrace();
                  return null;
              }
          }
  
          @Override
          protected void onPostExecute(String feed)
          {
              super.onPostExecute(feed);
  
              Parser(feed);
  
              progressDialog.dismiss();
          }
      }
  
      @SuppressLint("NewApi")
      void Parser(String x) 
      {
          if (x.contains(spliter_start))
          {
              if (spliter_end.isEmpty())
              {
                  x = x.substring(x.indexOf(spliter_start));
              }
              else
              {
                  x = x.substring(x.indexOf(spliter_start),
                          x.indexOf(spliter_end));
              }
  
          }
  
          int i = 0;
          list.clear();
          while (x.contains(loop_controller) &amp;&amp; i&lt;50)
          {
              /*if (i &gt; 50)
              {
                  break;
              }*/
  
              HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
              x = x.substring(x.indexOf(song_start));
  
  
              map.put("songsName",x.substring(
                      x.indexOf(song_start) + song_start.length(),
                      x.indexOf(song_end)));// songsName.get(i));
  
              x = x.substring(x.indexOf(song_url_start));
  
              map.put("songsUrl",x.substring(
                      x.indexOf(song_url_start) + song_url_start.length(),
                      x.indexOf(song_url_end)));// songsUrl.get(i));
  
  
              list.add(map);
  
              i++;
          }
  
          PlayListAdapter adapter = new PlayListAdapter(
                  PlayListActivity.this, list);
  
          list_of_songs.setAdapter(adapter);
  
      }
  </code></pre>
  
  <p>Can anybody tell me how to make it fast and responsive .. Or tell me a better way than AsyncTask.. And kindly tell me how to use thread to download a webpage. Or whether it is better or i  use some other way..</p>
  
  <p>AnyBody help me by viewing the code and tell me how can i make it fast. Someone told me to use HttpClient class instead of UrlConnection. which one is better. and is there any mistake i am doing due to which my app runs slowly.</p>
  
  <p>Thanks in Advance...</p>