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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:05:53+00:00 2026-05-28T08:05:53+00:00

In my onCreate, the following code executes: dialog = new ProgressDialog(this); dialog.setCancelable(false); dialog.setCanceledOnTouchOutside(false); dialog.setMessage(Welcome!

  • 0

In my onCreate, the following code executes:

dialog = new ProgressDialog(this);  
dialog.setCancelable(false);  
dialog.setCanceledOnTouchOutside(false);  
dialog.setMessage("Welcome! Initializing database... This will take just a minute");
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
dialog.setMax(100);
dialog.setProgress(0);
dialog.show();

The dialog should only go away once an AsyncTask completes. If I click home and then return to the application the ProgressDialog should still be there, and in fact, that’s what happens in the emulator. On my HTC Evo, however, the dialog does not show if I click home and return to the app.

I also have:

@Override 
protected void onRestart() {
    super.onRestart();
    try {
        dialog.show();
    }
    catch(Exception e) {}
}

Any ideas as to what could be causing this?

Updated (most relevant code):

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = this;
    RecipeDbAdapter rdAdapter;
    int recipesInDb = 0;

    // Binds automatically to "@android:id/list"
    setContentView(R.layout.country_list);
    setListAdapter(new EfficientAdapter(this));

    handler = new Handler() {
        public void handleMessage(Message msg) {
            Bundle b = msg.getData();
            String type = b.getString("type");
            String data = b.getString("data");

            // If message received to advance dialog (called during initial db load)
            try {
                if (type.equals("dialog")) {
                    dialog.incrementProgressBy(Integer.parseInt(data));

                    if (dialog.getProgress() >= dialog.getMax()) {
                        dialog.setProgress(dialog.getMax());
                        currentlyLoadingFromDb = false;
                        dialog.dismiss();
                        dialog = null;
                    }
                } else if (type.equals("update")) {
                    updateLastRecipeUpdateDate();
                }
            } catch (Exception e) {
            }
        }
    };

    try {
        rdAdapter = new RecipeDbAdapter(Countries.this);
        rdAdapter.open();
        recipesInDb = rdAdapter.fetchAllRecipesCount();
        rdAdapter.close();

        // Initialize database of recipes
        if (recipesInDb == 0) {
            currentlyLoadingFromDb = true;
            dialog = new ProgressDialog(this);
            dialog.setCancelable(false);
            dialog.setCanceledOnTouchOutside(false);
            dialog.setMessage("Welcome! Initializing database of recipes... This will take just a minute");
            dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            dialog.setMax(100);
            dialog.setProgress(0);
            dialog.show();
            updateLastRecipeUpdateDate();
            loadAT = new LoadDatabaseTask().execute("");
        }



        rdAdapter.close();
    } catch (Exception e) {
    }

}


@Override
protected void onPause() {
    try {
        dialog.dismiss();
    }
    catch(Exception e) {}
    super.onPause();
}

@Override
protected void onResume() {
    super.onResume();
    if (dialog!=null)
    try {
          dialog.show();
    }
    catch(Exception e) {}
  }

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

}
`

  • 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-28T08:05:53+00:00Added an answer on May 28, 2026 at 8:05 am

    your not restarting the application are you? if the async task is still going i assume that your app was just paused and will go through onResume instead. onResume should show it and onPause should dismiss it, if not create a taskbar notifier.

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

Sidebar

Related Questions

I have the following code: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.screen_database); db=new DBAdapter(this);
The following code executes a function that retrieves a file via ftp and then
Following code is used to insert data in the database. When application is launched,
this line is in onCreate function JSONObject cat = getJSONfromURL(http://localhost/2010/hkinterview/index.php?op=androidCat); The following code is
My code is as following . public void onCreate(Bundle savedInstanceState) { ................ ................ showDialog(CONTACT_DIALOG_ID);
I use following code : public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTheme(android.R.style.Theme_Wallpaper); setContentView(R.layout.main); }
I am using the following code to save/ load my picture OnCreate(){ super.onCreate(); setContentView(...)
i'm using following code to set visibility=gone for a linear layout //onCreate method //setcontentview
How to Play Video on OnCreate Method? I Used Following code for that.But The
I have the following code which gets call in my main activity's onCreate method

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.