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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:41:17+00:00 2026-05-24T07:41:17+00:00

When my application first starts it needs to do some set up. I’d like

  • 0

When my application first starts it needs to do some set up. I’d like to show a progress dialog while this is happening, so the user isn’t just faced with an unresponsive black screen. I am trying to do it with the following code, but the dialog never shows:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.shell);
    final ProgressDialog dialog = ProgressDialog.show(WhereWolfActivity.this, getString(R.string.loadingtitle), getString(R.string.loading), true, false);
    Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
            if(dbHelper == null)
                dbHelper = new WhereWolfOpenHelper(getApplicationContext());                    
            checkUserDetails();
            String providers = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
            checkLocationProviders(providers);
            runOnUiThread(new Runnable(){
                @Override
                public void run() {
                    dialog.dismiss();
                }                   
            });     
        }
    });
    thread.start();
}

If I remove dialog.dismiss(); the dialog shows up after the thread is finished. This suggests to me that the UI thread is being blocked. Any ideas how to fix this? Thanks.

  • 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-24T07:41:18+00:00Added an answer on May 24, 2026 at 7:41 am

    Your code works fine on a 2.3.3 Samsung Galaxy S i9000, I just checked (without the DB stuff, obviously – just Thread.sleep() before the runOnUIThread).

    Since this answer is not very helpful, let me point you to the class AsyncTask which has been created for the task you are currently doing “by hand”.

    Basically, you create a subclass of AsyncTask (as an inner class of your activity) – if you don’t need any parameters, just use Void,Void,Void – and start it in onCreate() with .execute();

    Kick off your progress dialog in onPreExecute(), do your background work in doInBackground, and finally dismiss the dialog in onPostExecute(). No fiddling with runOnUIThread.

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

Sidebar

Related Questions

Something equivalent to this command line: set PATH=%PATH%;C:\Something\bin To run my application, some thing
I have an application that when it first starts i need it to run
I have a windows form application which needs to be the TopMost. I've set
I'm trying to cache some application data that only needs to be instantiated when
I've got an application that needs to do some work on startup (before the
Here is how my application works: The user starts off filling out a form
in my application the first view is an UIView with a couple of uilabel
I am writing a quick application myself - first project, however I am trying
I am going to develop my first application (4 members team).I am not aware
I am close to finishing my first application (a UITableView style one) on the

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.