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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:54:32+00:00 2026-06-11T06:54:32+00:00

I am developing an Android app. There is an Activity which showing Button .

  • 0

I am developing an Android app. There is an Activity which showing Button.
When a button is pressed ProgressDialog should appear and behind ProgressDialog there should be another Activity that should open.
I want activity other then this Activity in which button is. How can I achieve this?

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.gamemenu);


    TextView tvStart = (TextView)findViewById(R.id.start);
    //TextView tvSettings = (TextView)findViewById(R.id.settings);
    TextView tvAbout = (TextView)findViewById(R.id.instruction);
    TextView tvExit = (TextView)findViewById(R.id.exit);

    tvStart.setOnClickListener(this);
    //tvSettings.setOnClickListener(this);
    tvAbout.setOnClickListener(this);
    tvExit.setOnClickListener(this);

}

public void onClick(View v) {

    switch(v.getId()){

    case R.id.start:

        ProgressDialog pd=new ProgressDialog(StartMenu.this);  
        pd=ProgressDialog.show(StartMenu.this,"Loading","Please Wait",false);  
        Handler handler=new Handler();
           Runnable gotologin=new Runnable() 
           {
           public void run() 
           {
            startActivity(new Intent(StartMenu.this,AndroidGame.class));
            finish();
           }
           };
           handler.postDelayed(gotologin, 3000);       
           pd.dismiss();    
        //   finish();     
          break;
     // Intent iStart = new Intent(getApplicationContext(), AndroidGame.class );
    //  startActivity(iStart);
    //  break;

    /*case R.id.settings:
        Intent iSettings = new Intent(getApplicationContext(), GameSettings.class );
        startActivity(iSettings);
        break;*/

    case R.id.instruction:
        Intent inInstructions = new Intent(getApplicationContext(), Instructions.class );
        startActivity(inInstructions);
        break;

    case R.id.exit:
        ((Activity)v.getContext()).finish();
        //this.finish();

        break;
    }

}
  • 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-06-11T06:54:34+00:00Added an answer on June 11, 2026 at 6:54 am

    You can show the ProgressDialog in this way.But,I don’t think this progressDialog would been seen as the new Activity would be loaded on the screen before you can show the ProgressDialog.

    ProgressDialog pd=new ProgressDialog(ActivityName.this);  
    Button n=new Button(ActivityName.this);  
    n.setOnClickListener(new OnClickListener() {  
    @Override  
    public void onClick(View v) {  
    
           pd=ProgressDialog.show(ActivityName.this,"Loading","Please Wait",false);  
           Intent i=new Intent(ActivityName.this,TargetActivityName.class)  
           startActivity(i);  
           pd.dismiss();    
           finish();     
       }  
    });
    

    If you want to show a ProgressDialog on click for Some time for your requirement,you can achieve that using Handler‘s that would load the the new Activity after some predecided time.

    A sample example which would hold the ProgressDialog for 3 Sec is as followed:

    ProgressDialog pd=new ProgressDialog(ActivityName.this);  
    Button n=new Button(ActivityName.this);  
    n.setOnClickListener(new OnClickListener() {  
    @Override  
    public void onClick(View v) {  
    
       pd=ProgressDialog.show(ActivityName.this,"Loading","Please Wait",false);  
    
       Handler handler=new Handler();
       Runnable gotologin=new Runnable() 
       {
       public void run() 
       {
        startActivity(new Intent(ActivityName.this, TargetActivityName.class));
        finish();
       }
       };
       handler.postDelayed(gotologin, 3000);       
       pd.dismiss();    
       finish();     
      }  
    });
    

    Required Answer:

    ProgressDialog pd;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.gamemenu);
    
    
        pd=new ProgressDialog(StartMenu.this);   // Edited here
    
    
        TextView tvStart = (TextView)findViewById(R.id.start);
        //TextView tvSettings = (TextView)findViewById(R.id.settings);
        TextView tvAbout = (TextView)findViewById(R.id.instruction);
        TextView tvExit = (TextView)findViewById(R.id.exit);
    
        tvStart.setOnClickListener(this);
        //tvSettings.setOnClickListener(this);
        tvAbout.setOnClickListener(this);
        tvExit.setOnClickListener(this);
    
    }
    
    public void onClick(View v) {
    
        switch(v.getId()){
    
        case R.id.start:
    
             runOnUiThread(new Runnable() {
    
             @Override
               public void run() {
                  pd=ProgressDialog.show(StartMenu.this,"Loading","Please Wait",false);  
                  Handler handler=new Handler();
                   Runnable gotologin=new Runnable() 
                   {
                    public void run() 
                    {
                      startActivity(new Intent(StartMenu.this,AndroidGame.class));
                      finish();
                    }
                   };
                  handler.postDelayed(gotologin, 3000);       
                  pd.dismiss();    
                  finish();  
    
                }
          });
          //     break;
         // Intent iStart = new Intent(getApplicationContext(), AndroidGame.class );
        //  startActivity(iStart);
        //  break;
    
        /*case R.id.settings:
            Intent iSettings = new Intent(getApplicationContext(), GameSettings.class );
            startActivity(iSettings);
            break;*/
    
        case R.id.instruction:
            Intent inInstructions = new Intent(getApplicationContext(), Instructions.class );
            startActivity(inInstructions);
            break;
    
        case R.id.exit:
            ((Activity)v.getContext()).finish();
            //this.finish();
    
            break;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A new question about android and services. Currently I'm developing a App that should
I'm developing an android app, and not understanding the back button. There is an
I am currently developing an android app, there is always unexpected exception popup when
I'm developing an Android client for a WCF service. There is a windows app
I'm developing an Android app in Eclipse Helios and I appear to have accidentally
When developing an Android app, is there a rule of thumb for when you
I have an Android app, in which Activities fire long running operations that run
Just starting out on android developing. To start off, I'm building an app which
I'm developing an app that we will put on Android tablets on be used
I'm developing an android app that has a bunch of screens (activities) that are

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.