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

  • Home
  • SEARCH
  • 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 6973997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:10:50+00:00 2026-05-27T17:10:50+00:00

How can I begin loading data for my activity as soon as my application

  • 0

How can I begin loading data for my activity as soon as my application starts? At the moment, I have it set up to download information needed as soon the the main screen is launched – which is where the user must login. Depending on the connection speed and how quickly the user logs in, the data may not be loaded and causes issues when the activity is launched, because the data hasn’t been loaded. (The spinner won’t have any data, etc.)

I currently have two AsyncTask – one for the login, and one to download the data. Once the user leaves the screen, it seems as though the AsyncTask stops. I tried putting a timer to wait until a boolean variable is set to true from the task which downloads the data, but that seems to force close the application. Here is an example:

while (!settingsLoaded) {
   SystemClock.sleep(1000);
}

When the AsyncTask that downloads the data hits the onPostExecute, I set settingsLoaded = true. Should I be using something else to download the data?

Note — when the application is launched, I do task.execute(); for the application data AsyncTask, and the other AsyncTask which logs in the users is set off dependent on whenever the users hits the ‘login’ button.

  • 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-27T17:10:50+00:00Added an answer on May 27, 2026 at 5:10 pm

    Now, you don’t mention what kind of data is being loaded – but from your description of scenario I would suggest you do something in the region of:

    1. User starts the application
    2. The Login-screen is shown
    3. User enters name/pass and hits “Login”
    4. AsyncTask to handle login is fired – A ProgressDialog is shown meanwhile.
    5. Login task finishes – the Main Activity is started.
    6. The data loading AsyncTask is fired – A ProgressDialog is shown while data is being loaded
    7. Data loading finishes, ProgressDialog dissappears and the user can start using the app.

    What most likely happens in your scenario is that the Login task finishes before the Data loading task. The way you do it at the moment you have no way of telling which task finishes first.

    If you want to start data loading right away, you could do it using a Service and then having the Main Activity show a ProgressDialog when it starts, if the Service is not done loading yet.

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

Sidebar

Related Questions

I am trying to learn PHP classes so I can begin coding more OOP
How can I drop all tables whose names begin with a given string? I
Can not run following SQL from ant's sql task : BEGIN DBMS_AQADM.CREATE_QUEUE_TABLE( queue_table =>
I'd like to begin thinking about how I can scale up my algorithms that
I have written a set of Win32 dlls that encapsulate a Delphi Frame (see
I have an application that prints text and images to pages on a printer.
Im working with FlashDevelop and have two main projects, all pure AS3 projects. When
I have written a c# win forms application that allows the user to open
I have a MDI application written in Delphi 2007. If the user exits a
Ok, I've looked all around, both here and on the web, and can't begin

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.