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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:17:40+00:00 2026-06-03T06:17:40+00:00

Here is my code Below. Here i m running a thread with a ProgressBar

  • 0

Here is my code Below. Here i m running a thread with a ProgressBar with a caption.

In run() of thread, if my internet connection is working then the ELSE part gets execute & dismiss that ProgressBar. But if my internet connection is not working then IF pat gets execute, here i m getting null exception when i try to dismiss ProgressBar. I have also added is null check if(m_ProgressDialog == null), and prints DialobBox in NULL..

Whats happening with my code.? ProgressBar dismissing in ELSE part but in IF is throw NULL Exception…

public void onCreate(Bundle savedInstanceState) {
.....................
.....................
//some CODE //
.....................
.....................
viewOrders = new Runnable(){
                @Override
                public void run() {
                    try {
                        if(!utilityFunctions.HaveNetworkConnection(SplashScreenActivity.this)) //checking internet connection
                        {
                            Log.i(UtilityFunctions.APP_TAG, "NO Connecttion");
                            //updateUI(0);
                            if(m_ProgressDialog == null)
                                Log.i(UtilityFunctions.APP_TAG, "DialogBox is NULL");
                            else
                                m_ProgressDialog.dismiss();

                            Log.i(UtilityFunctions.APP_TAG, "Dismissed");
                            handler.sendEmptyMessage(0);
                        }
                        else
                        {                                  
                            try {                                   
                                m_ProgressDialog.dismiss();                                                                 
                                }
                            } catch (Exception e1) {
                                // TODO Auto-generated catch block
                                e1.printStackTrace();
                            }                       


                            Intent mainIntent = new Intent().setClass(SplashScreenActivity.this, MainActivity.class);
                            Log.i(UtilityFunctions.APP_TAG, "Starting Program");                    

                            startActivity(mainIntent);
                            finish();
                        }
                    }
                    catch(Exception e) {
                        e.printStackTrace();
                    }

                }

                private Handler handler = new Handler()
                {
                    @Override
                    public void handleMessage(Message msg) {
                        //super.dispatchMessage(msg);
                        super.handleMessage(msg);
                        updateUI(msg.what);
                    }
                };  
            };

            Thread thread =  new Thread(null, viewOrders, "MagentoBackground");
            thread.start();
            m_ProgressDialog = ProgressDialog.show(SplashScreenActivity.this, "Please wait...", "Getting required data from server. This is an one time activity...", true);
}



public void updateUI(int code){
        Log.i(UtilityFunctions.APP_TAG, "updateUI");
        if(code == 0)
            Toast.makeText(SplashScreenActivity.this, "Unable to verify application signature. Please Check your internet connection & try again", Toast.LENGTH_LONG).show();
        else
            Toast.makeText(SplashScreenActivity.this, "Unable to process request. ", Toast.LENGTH_LONG).show();
}
  • 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-03T06:17:42+00:00Added an answer on June 3, 2026 at 6:17 am

    Try to declare ProgressDialog() at the top

    public void onCreate(Bundle savedInstanceState) {
    ....................
    .....................
    //some CODE //
    m_ProgressDialog = ProgressDialog.show(SplashScreenActivity.this, "Please wait...", 
    "Getting required data from server. This is an one time activity...", true);
    .....................
    viewOrders = new Runnable(){
                @Override
                public void run() {
                    try {
                          if(!utilityFunctions.HaveNetworkConnection(SplashScreenActivity.this)) //checking internet connection
                        {
                            Log.i(UtilityFunctions.APP_TAG, "NO Connecttion");
                            //updateUI(0);
                            if(m_ProgressDialog == null)
                                Log.i(UtilityFunctions.APP_TAG, "DialogBox is NULL");
                            else
                                m_ProgressDialog.dismiss();
    
                            Log.i(UtilityFunctions.APP_TAG, "Dismissed");
                            handler.sendEmptyMessage(0);
                        }
                        else
                        {                                  
                            try {                                   
                                m_ProgressDialog.dismiss();                                                                 
                                }
                            } catch (Exception e1) {
                                // TODO Auto-generated catch block
                                e1.printStackTrace();
                            }                       
    
    
                            Intent mainIntent = new Intent().setClass(SplashScreenActivity.this, MainActivity.class);
                            Log.i(UtilityFunctions.APP_TAG, "Starting Program");                    
    
                            startActivity(mainIntent);
                            finish();
                        }
                    }
                    catch(Exception e) {
                        e.printStackTrace();
                    }
    
                }
    
                private Handler handler = new Handler()
                {
                    @Override
                    public void handleMessage(Message msg) {
                        //super.dispatchMessage(msg);
                        super.handleMessage(msg);
                        updateUI(msg.what);
                    }
                };  
            };
    
            Thread thread =  new Thread(null, viewOrders, "MagentoBackground");
            thread.start();
    
    }
    
    
    
    public void updateUI(int code){
        Log.i(UtilityFunctions.APP_TAG, "updateUI");
        if(code == 0)
            Toast.makeText(SplashScreenActivity.this, "Unable to verify application   
    signature. Please Check your internet connection & try again", 
    Toast.LENGTH_LONG).show();
        else
            Toast.makeText(SplashScreenActivity.this, "Unable to process request. ",  
    Toast.LENGTH_LONG).show();
    }
    

    Hope this helps you..

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

Sidebar

Related Questions

I commented my code below to reflect what I am attempting to do here.
I had a weird problem here. Please check the code below. I do not
I have below code.The logic here is if HostList conatains any blanck entry it
Hey all. Here is the scenario. I have the below code, and I'm needing
I have some code as shown below: - (IBAction)startButtonPressed:(id)sender { statusText.text = @Processing...; //here
I'm trying to update an element in the XML document below: Here's the code:
As the code shows below, I'm creating a thread in a foreach loop and
All, I have a long running process that I run on a background thread
Here is the link to the sample code http://developer.apple.com/library/ios/#samplecode/MVCNetworking/Introduction/Intro.html Below is the code snippet
Ok the error is showing up somewhere in this here code if($error==false) { $query

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.