Skip to content Skip to sidebar Skip to footer

ProgressBar Betweed Activities

I have two activities. The first one executes the second one. Intent i = new Intent(MyOne.this, MyTwo.class); startActivity(i); The problem: My second activit

Solution 1:

I suggest you to do this asynchronously using AsyncTask.

Short example:

ProgressDialog dialog;
class YourTask extends AsyncTask<Void, Void, Void> {
        protected void onPreExecute() {
                   dialog = ProgressDialog.show(...);
        }

        protected Void doInBackground(Void... unused) {
            try {
               // doSomethingHeavy();
                   // publishProgress(...);
            } catch(Exception e) {
                //...
            } 

            return null;
        }

        protected void onProgressUpdate(Void... unused) {
        }

        protected void onPostExecute(Void unused) {
            dialog.dismiss();

        }
    }

Solution 2:


Post a Comment for "ProgressBar Betweed Activities"