title: Threaded web service call
body: <p>I am requesting information from a web service in my android app. The web service returns a list of items, each item having a base64 image and some info</p>
  
  <p>First method: simply access the web service and get the result. This means freeze of UI until data is downloaded. Not a good solution</p>
  
  <p>Second method: put the data download in a thread, and display a progress bar with a message. </p>
  
  <pre><code> private void StartGettingData()
      {
          viewInfo = new Runnable(){
              public void run() {
                  getData(); //from the web service
              }
          };
          Thread thread =  new Thread(null, viewInfo, "MagentoBackground");
          thread.start();
          progressDialog = ProgressDialog.show(TracksListActivity.this,    
                "Please wait...", "Retrieving data from WEB...", true);
      }
  
      private void getData(){
      {
        get data from web service into a list and then 
  
        runOnUiThread(returnRes);
      }
  
       private Runnable returnRes = new Runnable() {
  
       public void run() {
           populate the listview adapter with info from the web service result list and
  
           progressDialog.dismiss();
           generalTrackInfoAdapter.notifyDataSetChanged();
       }
   };
  </code></pre>
  
  <p>This shows a nice loading image and the message. The user will have to wait until all the download is complete. I don't know how to cancel the getdata() thread.</p>
  
  <p>Third method: I would like to have something like, the user presses a button to get data, a thread downloads item by item from the web service and immediate shows it in the list. The use can always cancel the request with a button press. </p>
  
  <p>But, how to do this ? Or is there another way ?</p>