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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:06:29+00:00 2026-05-27T06:06:29+00:00

I have an activity ‘Activity1’ and also another activity named ‘Activity2’. The ‘Activity2’ is

  • 0

I have an activity ‘Activity1’ and also another activity named ‘Activity2’. The ‘Activity2’ is loaded upon clicking a button in ‘Activity1’. I wanted to display the progress dialog until the new activity is loaded . Can you please show me the code to do this

  • 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-27T06:06:30+00:00Added an answer on May 27, 2026 at 6:06 am

    There is two ways to

    First approach To use Async Task

    If you are doing heavy tasks eg loading data from server or parsing xml in that case use AsynTask<>
    If you want to call ActivityB from ActivityA then

    *step-1*create a AsyncTask class. write all background tasks inside doBackground() method and after completion of task you want to call an activity that code write inside onPostExecute() post execute method

    import android.content.Context;
    import android.content.Intent;
    import android.os.AsyncTask;
    import android.view.View;
    
    
    
    public class LoadingDataFromServer extends AsyncTask {
        Context currentContext = null;
    
        boolean isCancelled = false;
    
    
        public LoadingDataFromServer(Context context) {
            currentContext = context;
    
        }
    
        @Override
        protected void onPreExecute() {
            if (DashboardActivity.progressBarLayout != null) {
                DashboardActivity.progressBarLayout.setVisibility(View.VISIBLE);
                // Log.i(TAG,".....Now make progress bar visible.....");
            }
    
            super.onPreExecute();
        }
    
        @Override
        protected Object doInBackground(Object... params) {
            // do background processing
    
            try {
    // do background tasks eg sever communication
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }
    
        @Override
        protected void onPostExecute(Object result) {
            // TODO Auto-generated method stub
            // progressDialog.dismiss();
    
            // call second Activity
            Intent i = new Intent(currentContext, com.ActvityB.class);
            super.onPostExecute(result);
        }
    
        @Override
        protected void onCancelled() {
            // TODO Auto-generated method stub
            isCancelled = true;
            super.onCancelled();
        }
    
    }
    

    step-2 In the activity fro where you want to jump to new activity (eg in ActivityA) call the execute() of AsynTask

    new LoadingDataFromServer(context).execute(null);
    

    Second approach

    • First show progress dialog.
    • create a thread to do all background tasks. when the thread completes
      the task then cancel the progress dialog and call the next activity

    or

    • when thread complets the task then call next activity pass this
      object (progress dialog) and inside that new activity dismiss this
      dialog.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a activity with 3 ImageView s and a Button . Clicking on
I have an activity that launches another activity with startActivityForResult method. I would like
I have an Activity named whereActity which has child dialogs as well. Now, I
I have Activity with ListView and buttons - clear all and OK. On button
let's have activity A and button in that activity, which opens activity A again.
I have a two layouts files in my app. Also I have Activity extends
I have an Activity that has all the display elements added dynamically. Theres no
I have Activity A with android:launchMode=singleTop in the manifest. If I go to Activity
I have Activity with ListView inside it and in the onCreate method of the
I have an activity that has a TabHost containing a set of TabSpecs each

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.