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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:58:33+00:00 2026-05-20T16:58:33+00:00

package com.em.progressb; public class progressb extends Activity implements OnClickListener { ProgressDialog dialog; int increment;

  • 0
package com.em.progressb;

public class progressb extends Activity implements OnClickListener {
    ProgressDialog dialog;
    int increment;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button startbtn = (Button) findViewById(R.id.startbtn);
        startbtn.setOnClickListener(this);
    }

    public void onClick(View view) { 

        // get the increment value from the text box
        EditText et = (EditText) findViewById(R.id.increment);
        // convert the text value to a integer
        increment = Integer.parseInt(et.getText().toString());

        dialog = new ProgressDialog(this);
        dialog.setCancelable(true);
        dialog.setMessage("Loading...");
        // set the progress to be horizontal
        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        // reset the bar to the default value of 0
        dialog.setProgress(0);

        // get the maximum value
        EditText max = (EditText) findViewById(R.id.maximum);
        // convert the text value to a integer
        int maximum = Integer.parseInt(max.getText().toString());
        // set the maximum value
        dialog.setMax(maximum);
        // display the progressbar
        dialog.show();

        // create a thread for updating the progress bar
        Thread background = new Thread (new Runnable() {
           public void run() {
               try {
                   // enter the code to be run while displaying the progressbar.
                   //
                   // This example is just going to increment the progress bar:
                   // So keep running until the progress value reaches maximum value
                   while (dialog.getProgress()<= dialog.getMax()) {
                       // wait 500ms between each update
                       Thread.sleep(500);

                       // active the update handler
                       progressHandler.sendMessage(progressHandler.obtainMessage());
                   }
               } catch (java.lang.InterruptedException e) {
                   // if something fails do something smart

               }
           }
        });

        // start the background thread
        background.start();

        progressb o1 = new progressb();
        o1.onPause();


 if(dialog.getProgress()==dialog.getMax())
 {    
      Intent i = new Intent(this, ShowMyDialog.class);
         this.startActivity(i);
 }   


    }

    // handler for the background updating
    Handler progressHandler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.incrementProgressBy(increment);
        }
    };
}

This is my code of 1st activity.it contains progress bar,as progress reached max limit i want to call 2nd activity and also i have written intent to call next activity.
but its not working.please help me to solve 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-20T16:58:33+00:00Added an answer on May 20, 2026 at 4:58 pm

    Move your code which calls the next activity to the handler. The bg thread that you’ve created runs parallel to the UI thread.

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

Sidebar

Related Questions

package com.example.android.home; import android.app.Activity; import android.os.Bundle; import android.widget.*; import android.view.*; public class HomeActivity extends
package com.valami; public class Ferrari { private int v = 0; private void alam()
package com.test01; public class test01 { public static void main(String[] args) { System.out.println(hi); }
package com.parseador.prueba; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.EditText; public class main extends
package com.comboyz.TantaGo; import android.app.ListActivity; import android.os.Bundle; import android.widget.ArrayAdapter; public class startMenu extends ListActivity{ @Override
package com.openwaf.test.basic; public class MethodArgumentTest { static interface Inf{} static class One<E extends Inf
I have a config file like package com.mypackage.referencedata.config; @Configuration @ComponentScan (com.mypackage.referencedata.*) public class ReferenceDataConfig
this is my custom dialog class: package com.WhosAround.Dialogs; import com.WhosAround.AppVariables; import com.WhosAround.R; import com.WhosAround.AsyncTasks.LoadUserStatus;
Please consider the following java source: package com.stackoverflow; public class CondSpeed { private static
My test is defined as follows: package com.mytest; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration public class SpringTestCase {

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.