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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:14:11+00:00 2026-06-15T14:14:11+00:00

I have a class which generates a pdf file. This class is extended by

  • 0

I have a class which generates a pdf file.
This class is extended by Activity that means is have onCreate, onPause (and so on) methods.

While a pdf file is generating it takes some time to be generated so I need to show a progress bar to notify the user that the file is generating at the moment.

Everything works fine expect that when I click on a generate button the progress bar freezes for a few seconds (according to Logcat: progress bar freezing while file is generating).

So my problem is that, that I don’t know how to make the progress bar unstoppable while the file is generating.

Below is my code:

Log.i(TAG, "PDF generation: " + position);

final ProgressDialog dialog = new ProgressDialog(this);
dialog.setCancelable(true);
dialog.setIndeterminate(true);
dialog.setMessage("Generating...");
dialog.show();

new Thread(new Runnable() {

    @Override
    public void run() {

        startActivity(new Intent(getApplicationContext(),
            PdfGenerator.class));

        runOnUiThread(new Runnable() {

            @Override
            public void run() {
                dialog.hide();
            }
        });

    }

}).start();
  • 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-15T14:14:12+00:00Added an answer on June 15, 2026 at 2:14 pm

    Change your code as for starting an Activity from Thread using runOnUiThread:

    ///... your code here..
    
        new Thread(new Runnable() {
    
            @Override
            public void run() {
    
                Your_Current_Activity.this.runOnUiThread(new Runnable() {
    
                    @Override
                    public void run() {
    
                    dialog.cancel();
    
                    // START ACTIVITY HERE
                   Your_Current_Activity.this.startActivity(new 
                            Intent(Your_Current_Activity.this,
                                           PdfGenerator.class));
    
                    }
                });
    
            }
    
        }).start();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have written this little class, which generates a UUID every time an object of
I have class A which extends the Activity class. This class is in package
Let's assume that we have a PHP class Page , which generates PHP Page
I have a class which generate PDF dynamically, in that I have a 4-6
I have a class which generates events e.g. public class EventSource{ public addEventListener(EventListener listener).....
I have class Employee which is something like this. class Emp { int EmpID;
I have added a link on a page clicking on which generates a pdf
I have a link on a page which generates a pdf. I am using
I have a class which generates a form and controls. The controls vary between
I have a class in my Prism/CAL application which generates a form for users

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.