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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:28:41+00:00 2026-06-08T13:28:41+00:00

Sir, I am trying to handle the message if there is no internet connection.

  • 0

Sir, I am trying to handle the message if there is no internet connection. But null exception error occurs when I still proceed download if there is any network connection. At first, it shows the message for error in network connection but when I press yes, the exception error message pops out. What shall we handle further when we handle this case?

   timer = new Timer();
    boolean isOnline = WebServiceHandler.isOnline(this);
    if (isOnline) {
        startDownloadTask();
     task = new TimerTask() {

            @Override
            public void run() {
                // TODO Auto-generated method stub
                int progress = downloadProgressBar.getProgress();
                notification.contentView.setProgressBar(R.id.pb, downloadProgressBar.getMax(), progress, false);
                nm.notify(notificationID, notification);
            }
        };

        timer.schedule(task, 10, 500);

    } else {
        connectionErrorDialog.show();
        onDestroy();


    }

}    




@Override
public void stopDownloadTask() {
    downloadGoodListTask.cancel(true);
    downloadGoodListTask.setActivityIsRunning(false);
    downloadGoodListTask = null;

}


 protected void onDestroy() {
    super.onDestroy();
    Log.i("Download Activity", "starting to destroy");
    //timer.cancel();


    wheelProgressBar.destroyDrawingCache();
    downloadProgressBar.destroyDrawingCache();
    finishDialog.dismiss();
    connectionErrorDialog.dismiss();

    downloadProgressBar = null; 
    wheelProgressBar = null;
    progressTextView = null;
    downloadingTextView = null;
    finishDialog = null;
    connectionErrorDialog = null;        
    //timer = null;     
    nm.cancel(notificationID);

    nm = null;
    notification = null;
    /*downloadTask.cancel(true);
    downloadTask.activityIsRunning = false;
    downloadTask = null;*/
    stopDownloadTask();
    timer.cancel();        
    System.gc();

    Log.i("Download Activity", "destroyed");
}


@Override
public void stopDownloadTask() {
    downloadGoodListTask.cancel(true);
    downloadGoodListTask.setActivityIsRunning(false);
    downloadGoodListTask = null;

}
  • 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-08T13:28:42+00:00Added an answer on June 8, 2026 at 1:28 pm

    do not access the Android UI toolkit from outside the UI thread. Use runOnUIThread method, send message to a Handler or use AsyncTask.

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

Sidebar

Related Questions

I am trying to implement the SIR epidemic model . Basically, the way I
Sir, these days i am improving my recursion skills but i am stuck in
I am trying to create a simple simulation program of SIR-epidemics model in java.
this might be a long message but i would like to give a clear
sir i have got an error while running my project in ecclipse. The error
Sir, Here i need to add geolocation from metadata to uiimage but after adding
am trying to select a multi select combo box. There i have to customize
I am trying to send newsletter but when I entered text like: 2nd year,
Respected Sir! As i have not learnt java yet but most people say that
I get these results via php to alert in my ajax alert [{message_id:3,box:0,from_id:3,to_id:1,title:Hello sir!,message:how

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.