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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:31:16+00:00 2026-05-28T04:31:16+00:00

My main application does this: It retrievs data from the internet and has 3

  • 0

My main application does this: It retrievs data from the internet and has 3 button, when OnClicked, i am going to 3 other screens. because the data loading may be a little slow, I want to use an async Task. This is my sample code for asynctask.

class LoginProgressTask extends AsyncTask {
        @Override
        protected Boolean doInBackground(String... params) {
            try {
                Thread.sleep(4000);  // Do your real work here
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return Boolean.TRUE;   // Return your real result here
        }

        @Override
        protected void onPreExecute() {
            showDialog(AUTHORIZING_DIALOG);
        }

        @Override
        protected void onPostExecute(Boolean result) {
            // result is the value returned from doInBackground
            removeDialog(AUTHORIZING_DIALOG);
        }
}

and this is my sample of my main activity:

public class MainScreen extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        MainTheme();
    }
    public void MainTheme(){
         retrieve_data(); //function for getting the data
         ... action with the buttons, onClicks Listener
    }
}

My question is how can I mix those codes in One activity to make it work, becuase I haven’t understood AsyncTask. Or what I should return in the doInBackground?

  • 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-28T04:31:17+00:00Added an answer on May 28, 2026 at 4:31 am

    I learned it from >> AsynTask link. may be it will helpful to you too, first read the whole example then start applying it on your code.

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

Sidebar

Related Questions

I have a C# windows application which does the following: 1) the main form
I have my main application ,from my main application I will be calling another
So I have a UIViewController (main application controller is a TabBarController). On this there
I want to download a file from internet and I imagine this should be
Our main application has both a asp.net and winforms component. There is a class
Long story short, I have a substantial Python application that, among other things, does
I have a Main WPF application and other modules and I am using PRISM
Why does this code takes 0.32 CPU hours and has an avreage memory of
I'm expanding on the hello world application. I've created a button on the main.xml
I have my main application delegate which contains a method that returns an object.

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.