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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:06:32+00:00 2026-05-19T03:06:32+00:00

I have a problem with progress dialog on opening an activity (called activity 2

  • 0

I have a problem with progress dialog on opening an activity (called activity 2 in example).

The activity 2 has a lot of code to execute in this OnCreate event.

final ProgressDialog myProgressDialog = ProgressDialog.show(MyApp.this,getString(R.string.lstAppWait), getString(R.string.lstAppLoading), true);
new Thread() {
    public void run() {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                showApps();
            }
        });
        myProgressDialog.dismiss();
    }
}.start(); 

The showApps function launch activity 2.

If I execute this code on my button click event on activity 1, I see the progress, but she doesn’t move and afeter I have a black screen during 2 or 3 seconds the time for android to show the activity.

If I execute this code in the OnCreate of Activity2 and if I replace the showApps by the code on OnCreate, Activity1 freeze 2 seconds, I don’t see the progress dialog, and freeze again 2 seconds on activity 2 before seeing the result.

  • 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-19T03:06:33+00:00Added an answer on May 19, 2026 at 3:06 am

    I had the same issue and using an AsyncTask is working for me.

    There are 3 important methods to override in AsyncTask.

    1. doInBackground : this is where the meat of your background
      processing will occur.
    2. onPreExecute : show your ProgressDialog here ( showDialog )
    3. onPostExecute : hide your ProgressDialog here ( removeDialog or dismissDialog
      )

    If you make your AsyncTask subclass as an inner class of your activity, then you can call the framework methods showDialog, dismissDialog, and removeDialog from within your AsyncActivity.

    Here’s a sample implementation of AsyncTask:

    class LoginProgressTask extends AsyncTask<String, Integer, Boolean> {
      @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);
        Intent i = new Intent(HelloAndroid.this, LandingActivity.class);
        startActivity(i);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem I created my progress dialog dialog = new ProgressDialog(InstallerActivity.this); I
Actually i have a problen while using progress dialog.The problem is not with the
I have an interesting problem. I need to do a progress bar from an
I have problem with my query on C, I’m using the oci8 driver. This
I have problem developing with live555. I already build the lib-files and example projects
The first activity in my app is a splash screen with a Progress Dialog
I have a problem showing my progress bar when reading a file in Java.
I'm new to android and have been stuck on this problem for a long
i have the following code. When i am trying to call SongSearch.execute(searchterm); the app
I try to use a progress dialog. My code: //Method to load data wire

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.