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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:42:43+00:00 2026-05-23T08:42:43+00:00

I have several timers that poll information off the internet. When I get an

  • 0

I have several timers that poll information off the internet. When I get an error trying to do so, I check the network connectivity, and if it is not available, then I stop the timers. My issue is that I want to restart the timers when the network becomes available again.

The issue is that if the network goes away and doesn’t come back for a long time, then probably every part of my app that was running has now been killed or so. My question is…where do I create my network connectivity changes receiver so that it will always be able to respond to those events? Obviously not in an activity.

I had originally put it in an extended Application class. I’m not sure if that was correct, and I’m finding now that even that goes away, but gets created again any time some part of your app gets utilized. So is that still the correct place?

I’m also a bit confused…I had thought to create a standalone receiver class to monitor the network changes and then restart the timers if it got a connection message. But then I thought….what would instantiate this? If nothing did, then how would it work? But the same question then goes to my OnBootReceived class….I do nothing to instantiate that class anywhere and register it, yet it still works! (Other than putting it in the AndroidManifest and the BOOT_COMPLETED intent filter). Is that kind of receiver special? I tried doing the same thing with my network change receiver, but it never responded to any network changes. When I finally put it in my application class, instantiated it, and registered it, THEN it received the broadcasts.

I have code, but this is kind of a code-independent question. I’m trying to clear up WHERE my code goes. IF I get past that and it still doesn’t work, I can post it.

So, I’m almost understanding. If I do nothing more than have this in my code, will I receive messages when the connectivity state changes? Because if so, I’m not receiving any and this is what I have.

Or do I need to register this on boot somehow? The video mentions using the manifest intent filter to get updates when your app isn’t running, but doesn’t show if it still needs to be registered somehow somewhere (and if you DO register, aren’t you registering an instance, and if so, won’t that instance disappear when whatever object you were registering it in goes away?)

Code:

public class NetworkConnectivityReceiver extends BroadcastReceiver {

    Context context;

    @Override
    public void onReceive(Context context, Intent intent) {



        Log.d(TAG, "Connection message received.");

    }

}


    <receiver android:name=".NetworkConnectivityReceiver" >
        <intent-filter>
            <action android:name="android.net.ConnectivityManager.CONNECTIVITY_ACTION"></action>
        </intent-filter>
    </receiver>
  • 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-05-23T08:42:44+00:00Added an answer on May 23, 2026 at 8:42 am

    Take a look at the video below from google io 2011, around about 28mins it covers connectivity changes, and helped me out alot when i was doing this.

    http://youtu.be/twmuBbC_oB8

    You would probably need to use an Intent to monitor the connectivity changes, setup a pending intent to broadcast whenever the connectivity changes then setup a broadcast receiver to process the change. (the video show something similar but with location changes at around 22 mins)

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

Sidebar

Related Questions

I know that this question have been asked several times. But I can't get
I have several timers scheduled to play music at pre-determined intervals. I'm trying to
I have several javascript files that during run-time get combined and minified. This is
I have a flex app that has several timers running for various amounts of
I have an application (winform exe) that I run several times. Does this mean
Several times in my career, I have worked in a software group that determined
I have had to do this several times, usually when trying to find in
We have several sites that use Forms Based authentication (FBA) within SharePoint. Many of
I have an object that uses a timer to occasionally poll for a resource
We have a GUI of several frames that build their contents dynamically. Each frame

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.