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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:17:01+00:00 2026-06-14T00:17:01+00:00

I am having a progress dialog for a process. But i am taking a

  • 0

I am having a progress dialog for a process. But i am taking a null pointer exception in my thread. But, when i remove the progress dialog. I am no longer taking an exception.

My code is as this

public class PlayedActivity extends ListActivity {

private PullToRefreshListView listView;

final Context context = this;

public Handler handler;

Runnable sendNumbers2;

List<On> playedOn;

DatabaseHandlerOn db;

private ProgressDialog m_ProgressDialog;

private ArrayList<On> m_results = null;
private PlayedOnAdapter m_adapter;



    @SuppressLint({ "HandlerLeak", "HandlerLeak" })
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_playedonnumara);


            db = new DatabaseHandlerOnNumara(getApplicationContext());

            m_results = new ArrayList<OnNumara>();

        this.m_adapter = new PlayedOnNumaraAdapter(this, R.layout.playedrowon, m_results);
        this.setListAdapter(this.m_adapter);

        sendNumbers2 = new Runnable() {

            @Override
            public void run() {

                playedOn = db.getAllContacts();      

                for (On on : playedOn) {

                    m_results.add(on);  

                }  


                Collections.reverse(m_results);

                //m_ProgressDialog.dismiss();

                handler.sendEmptyMessage(0);
            }
        };
            Thread thread = new Thread(sendNumbers2,"sendNumbers2");
            thread.start();

            /*m_ProgressDialog = ProgressDialog.show(PlayedOnNumaraActivity.this,
                    "",getString(R.string.PleaseWait), true);

            m_ProgressDialog.setCancelable(true);
        */

            handler = new Handler() {
                @Override
                public void handleMessage(Message msg) {


                    m_adapter.notifyDataSetChanged();


                }

             };

        }
}

}

The code above is working and takes no exception when progress dialog codes are commented

  • 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-14T00:17:02+00:00Added an answer on June 14, 2026 at 12:17 am

    Without your LogCat logs, I can only guess.

    m_ProgressDialog is defined after you start your thread. Why? Define it before the thread is started.

    Also, I would recommend an AsyncTask for this, instead. See Painless Threading for details on that.

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

Sidebar

Related Questions

I am having below code but Progress Dialog never gets dismissed even after progress
Firs of all thanks for reading this. I'm having trouble updating the progress from
I am trying to dismiss a progress dialog but it doesnt seem to work
I'm having real problems getting a ProgressDialog up and running. My code: ProgressDialog dialog;
I thought I wouldn't need to ask this but I am not having any
The Progress docs spill plenty of ink on SOAP, but I'm having trouble finding
This question has been asked before but, I'm a newbe and having issues trying
Sorry for the many posts here regarding this issue but i am having a
I am having a little difficulty with a generic template for my extended progress
Having trouble with each function... Will try to explain by example... In my code,

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.