Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1089903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:17:45+00:00 2026-05-16T23:17:45+00:00

I am requesting information from a web service in my android app. The web

  • 0

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

First method: simply access the web service and get the result. This means freeze of UI until data is downloaded. Not a good solution

Second method: put the data download in a thread, and display a progress bar with a message.

 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();
     }
 };

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.

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.

But, how to do this ? Or is there another way ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:17:45+00:00Added an answer on May 16, 2026 at 11:17 pm

    You can use AsyncTask for threading, basics: painless threading, example:Multithreading For Performance(image downloader).

    Because using the class thread or the interface runnable your code becomes more complicated and more difficult to read. It becomes even worse when you implement complex operations that require frequent UI updates.

    The goal of AsyncTask is to take care of thread management for you.

    The basic structure is:

    public class DownloaderTask extends AsyncTask<String, String, String>{
    
        protected void onPreExecute(){}
    
        protected String doInBackground(String....args){
            //do something in background
        }
    
        protected void onProgressUpdate(String str){}
    
        protected void onPostExecute(String result){
             //..update ui
        }
    }
    

    …to start your task e.g.:

    public void onClick(View v){
         new DownloaderTask().execute("param");
    }
    
    • The method doInBackground() executes
      automatically on a worker thread

    • onPreExecute(), onPostExecute() and
      onProgressUpdate() are all invoked on
      the UI thread

    • The value returned by
      doInBackground() is sent to
      onPostExecute()

    • You can call publishProgress() at
      anytime in doInBackground() to
      execute onProgressUpdate() on the UI
      thread

    • You can cancel the task at any time,
      from any thread

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am pulling back information about locations from a webservice. The service returns an
My JavaScript code puts up a dialog box requesting some information from a user,
i am having no problem at all compiling/debugging my web app, but when i
im requesting information from the instagram api in php like this: <?php $relation =
I'm requesting information from a remote server which is sent back to me as
I am currently developing an app which downloads information from a webservice which I
I'm requesting an internal API with lots of different interface, each is REST :
One of our 'frontend' developers keeps requesting from us backend developers that the backend
I've been doing web development for a few months now and keep having this
I am getting invalid identifier problem while requesting for product information I have done

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.