Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Progress bar not hiding [duplicate]

Tags:

android

I have a dashboard section in my android application where once a user clicks on a button, a preogressDialog is show ("Please Wait") and the next activity loads up. But when i click the android device bacj button, the progress bar is still showing up. I used dismiss() but to no use. Any help is appreciated.

progressDialog.setMessage("Please wait...");
progressDialog.setIndeterminate(true);
progressDialog.setCancelable(true);
progressDialog.show();
browseCategories();

protected void browseCategories() {
        Log.i(MY_DEBUG_TAG, "Bow!");
        Intent c = new Intent(this, CategoryListActivity.class);
    c.putExtra("user", u);
    startActivity(c);
}
like image 652
Sanjai Palliyil Avatar asked Feb 03 '26 16:02

Sanjai Palliyil


1 Answers

Using a progress dialog in an activity immediately before starting another one doesn't make sense.

Activities are, for the most part, meant to be UI-oriented and when one starts another then the new one is 'layered' over the top of the first.

If the CategoryListActivity is going to take some time before it is ready for use (loading data for example), then it should show a progress dialog and not the activity that starts it. Using an AsyncTask for loading data or any operation which will take an extended time is the best way to proceed.

I suggest you read about Application Fundamentals and the Activity Lifecycle

like image 95
Squonk Avatar answered Feb 06 '26 06:02

Squonk