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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:28:50+00:00 2026-06-11T08:28:50+00:00

I have an Activity A1 and a ListActivity A2 I take inputs from user

  • 0

I have an Activity “A1” and a ListActivity “A2”

I take inputs from user in Activity “A1” and depending on the inputs given by user I process and generate a result list. The list generated will then be shown in my ListActivity “A2”.

Now, processing the inputs and generating the result list takes a bit too long. So I want to show a loading dialog or loading image or loading message in this time so the user won’t think that the app is stuck up doing nothing.

Now the things I tried so far:
Yes, I tried AsyncTask! (I know many people are about to suggest it) So now I am doing all my processing in an AsyncTask. I am showing a ProgressDialog in onPreExecute, doing my processing in doInBackground and dismissing the dialog onPostExecute.

However, the dialog comes just before the ListActivity “A2” starts. Until then the Activity “A1” just seems to be stuck up!

I want the dialog to show up right when I click the “Submit” button on Activity “A1” and continue to be seen until ListActivity “A2” shows up.

Please let me know if you need anymore details. Thanks.

–EDIT–

Code in onClick method:

ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Processing... Please Wait...");
progressDialog.show();
// Execute task
MyTask myTask = new MyTask(progressDialog);
AsyncTask<String, Void, ArrayList<HashMap<String, String>>> result =
    myTask.execute(userChoice);
Intent intent = new Intent(this, ListActivityA2.class);
// Put results in intent
intent.putExtra("results", resultsList);
// Start result activity
startActivity(intent);

AsyncTask

public class MyTask extends
            AsyncTask<String, Void, ArrayList<HashMap<String, String>>> {

        ArrayList<HashMap<String, String>> resultsList =
                    new ArrayList<HashMap<String, String>>();
        ProgressDialog progressDialog;

        public MyTask(ProgressDialog progressDialog) {
            this.progressDialog = progressDialog;
        }

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
        }

        @Override
        protected ArrayList<HashMap<String, String>> doInBackground(
                String... params) {
            return doProcess(params[0]);
        }

        @Override
        protected void onPostExecute(ArrayList<HashMap<String, String>> result) {
            progressDialog.dismiss();
            super.onPostExecute(result);
        }

        private ArrayList<HashMap<String, String>> doProcess(String choice) {

            // do processing here
            return arrayList;
        }
}
  • 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-11T08:28:52+00:00Added an answer on June 11, 2026 at 8:28 am

    I have solved this!

    I moved the code to create Intent to onPostExecute

    The reason behind this: the UI thread (Activity “A1”) was anyway waiting for the AsyncTask to return the results so that it could show the ListActivity “A2”

    Now that the creating intent and starting ListActivity “A2” is happening in onPostExecute the UI thread can work without freezing.

    Thanks for all ur help @Aswin Kumar!

    Hope this question and answer helps others. 🙂

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

Sidebar

Related Questions

I have a Contact Activity which is derived from ListActivity, which displays list of
I have following goal: From a list in main activity that extends ListActivity, I
In android, I have a List Activity (subclass from ListActivity). And i want to
I have an Activity that plays some audio from within a ListActivity . The
I have a activity (ListActivity) in which if a user click on a button,
I have one android activity which extends ListActivity. Every time list items is pressed
I have an activity inherited from ListActivity and using AndroidAnnotations. While .onListItemClick works fine,
I have a list activity which display all running applications in the device. it's
Right now I have a list activity powered by a cursor adapter. I have
Sorry for my English. I have my own ArrayAdapter for list activity . My

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.