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 8539283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:19:40+00:00 2026-06-11T11:19:40+00:00

I have an asynctask that is in its own activity. I pass it a

  • 0

I have an asynctask that is in its own activity. I pass it a string value and it connects to my web service and downloads Json data based on the name I pass in, returning the Json resultset. Works great.

I’d like to add a progress spinner to the asynctask, but I’m stymied as to how to do it. I’ve perused this and many other blogs, and come close but have not yet found the solution. It seems I either need to have the asynctask in with an Activity class to get the context or I have to pass in the context as a parameter — but I need the input parameter to be String. I’ve read about the possibility of building an Object that could hold the String and a Context parameter, but I’m very new to Java and don’t know how to build something like that nor have I found a good explanation of how to do so. So often an explanation gets right up to what I need and then says, “… and then you do X and that’s it,” when X is what I need to know.

All I want is just a spinner thingie to whirl while the download happens. No text, no dialog, just a spinner.

  • 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-06-11T11:19:41+00:00Added an answer on June 11, 2026 at 11:19 am

    Add a ProgressBar(this is what it’s actually called, Spinners are like drop down menus in Android) to the layout of the Activity where you’re initializing your AsyncTask.

    Then make two functions startProgress() and stopProgress(), which start and stop the progress bar.

    Give your AsyncTask a reference to the Activity, either by sending it during initialization or execution, or making a function in your asyncTask setActivity(MyActivity activity) and call it between your AsyncTask initialization and execution.

    Override the onPreExecute() of your AsyncTask to call activity.startProgress() and onPostExecute() to call activity.stopProgress().

    EDIT: You can also try passing a reference to the ProgressBar in the constructor of your AsyncTask. Get the reference to the ProgressBar in the onCreate() method of your activity, then add it in the AsyncTask constructor. In the onPreExecute() and onPostExecute() methods of the AsyncTask, start and stop the progress bars accordingly.

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

Sidebar

Related Questions

I have a PreferenceActivity that gets its data from a web service(Call forward Numbers,
I have an AsyncTask and on the background I want to start Service that
I have an Activity class which has an attribute that references an AsyncTask instance
I have an Activity Class with an inner protected class that extends AsyncTask. I
I have an asynctask that reads data from a device and then I want
I have a code that downloads videos from a URL. I am using AsyncTask.
I have a AsyncTask that runs and does its job and completes. onPostExecute does
i have developed a simple AsyncTask class that takes Handlers as its parameters and
I have an activity which, during its execution, kicks off a couple of AsyncTask
I have a service that performs a slow task, when its finished I want

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.