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

  • Home
  • SEARCH
  • 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 8170263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:05:53+00:00 2026-06-06T21:05:53+00:00

I have the following three classes: When I try to show a progressDialog when

  • 0

I have the following three classes:

When I try to show a progressDialog when the WorkingThread is running, the ProgressDialog only shows up after the WorkingThread is done. What am I doing wrong?

I am not interested in using an AsyncTask!

-StartActivity:

public class StartActivity extends Activity implements OnClickListener
{
    public ProgressDialog pgd;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        imgv = (ImageView)findViewById(R.id.imageView1);
        tv = (TextView)findViewById(R.id.textview);

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

    public void onClick(View v) 
    {
        pgd = ProgressDialog.show(StartActivity.this, "", "Loading picture"); // Start ProgressDialog before starting activity

        Intent ActivityIntent = new Intent(this, FirstActivity.class);
        startActivityForResult(ActivityIntent, 0);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) 
    {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == 0 && resultCode == RESULT_OK)
        {
            pgd.dismiss(); //Stop ProgressDialog when FirstActivity is "done"
        }
    }
}

–

-FirstActivity:

public class FirstActivity extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);

        WorkingThread wt = new WorkingThread();
        wt.start();

        try 
        {
            wt.join();
            Intent ActivityIntent = getIntent();
            setResult(RESULT_OK, ActivityIntent);
            finish();
        } 
        catch (Exception e) 
        {
        }
    }
}

-WorkingThread:

public class WorkingThread extends Thread 
{

    @Override
    public void run() 
    {
        super.run();

        try
        {
            Thread.sleep(5000);
        }
        catch (Exception e)
        {
        }
    }
}
  • 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-06T21:05:54+00:00Added an answer on June 6, 2026 at 9:05 pm

    The problem is ProgressDialog always need current Activity context for display.But in your case ProgressDialog is little unfortunate

    The reason is as soon as you fire ProgressDialog the next couple of lines take out Context from Current activity and starts Next Activity i.e FirstActivity.So your progressDialog gets no chance to present itself on the Screen.

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

Sidebar

Related Questions

I have the following problem. I have three classes, A, B and C. A
In my project I have the following three interfaces, which are implemented by classes
Let's say I have following classes. (only most important things included) public class Client
I have the following classes: public class MyClass { public void MyMethod() { try
I have three classes with the following associations: class Technician < ActiveRecord::Base has_many :tickets
I have following use-case: there are several assemblies decorated with ProtoContract classes and I
I have the following three items displayed side by side: <div class=page-header> <h1 style=line-height:0>Title</h1>
I have the following three files in the same directory: citysim.cpp #include utils.h using
I have the following three arrays and need to create a new two-dimensional array
I have the following three tables. I am trying to inter link (join) among

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.