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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:06:38+00:00 2026-06-09T15:06:38+00:00

This post may seem long.. But it’s very simple. So please please help. Thanks.

  • 0

This post may seem long.. But it’s very simple. So please please help. Thanks.

In short words, Whenever there is Connectivity change from Wifi to Mobile, I receive a message in my Broadcast receiver 2 times(First time NO Network is found). And when I move from Mobile to Wifi, I receive it three times. Can anyone please explain me this strange behavior.

I have implemented a code using IntentFilterConnectivityManager.CONNECTIVITY_ACTION) and registered it to my receiver.

IntentFilter mNetworkStateFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);

registerReceiver(mNetworkStateReceiver , mNetworkStateFilter);


private final BroadcastReceiver mNetworkStateReceiver = new BroadcastReceiver() 
          {

            @Override
            public void onReceive(Context context, Intent intent) 
            {
                  //The Network State has Been Changed
                  Log.d(TAG, "CHANGE HAPPENED" );

                 if (networkInfo != null)
        {
            Log.d(TAG, "Connected To: " + networkInfo.getTypeName());
            Log.d(TAG, "NUMBER: " + networkInfo.getType());
            Log.d(TAG, "isConnectedOrConnecting: " + networkInfo.isConnectedOrConnecting());
            Log.d(TAG, "isConnected: " + networkInfo.isConnected());
            Log.d(TAG, "isFailover: " + networkInfo.isFailover());
            Log.d(TAG, "Reason :" + networkInfo.getReason());
            Log.d(TAG, "Details " + networkInfo.getDetailedState() );


            boolean noConnectivity = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
            String reason = intent.getStringExtra(ConnectivityManager.EXTRA_REASON);
            boolean isFailover = intent.getBooleanExtra(ConnectivityManager.EXTRA_IS_FAILOVER, false);



            Log.d(TAG, "noConnectivity: " + noConnectivity);
            Log.d(TAG, "reason: " + reason);

            Log.d(TAG,"DONE");

        }       


            }
      };

I have observed the following behavior. Can anyone please explain the reason for this happening.

Initially My Device is connected to Wifi.

The APK is now Deployed on the Device.

My Logcat entry is
D/MainActivity(32005): CHANGE HAPPENED
D/MainActivity(32005): Connected to WIFI

This is understandable.

Now the Router is turned off. So now the device attempts to connect to 4G.
Now, the Logcat Entry is as follows.

D/MainActivity(32005): CHANGE HAPPENED
D/MainActivity(32005): CHANGE HAPPENED
D/MainActivity(32005): Connected to Mobile

May be this can be attributed to the fact the first the connection is broken, which causes CHANGE HAPPENED to be printed but not the Message “Connected to “. And then the connection is established with Mobile resulting in another CHANGE HAPPENED with Connected to Mobile.

Now the router is turned on again.

But this time the logcat reports,
D/MainActivity(32005): CHANGE HAPPENED

D/MainActivity(32005): Connected to WIFI

D/MainActivity(32005): CHANGE HAPPENED

D/MainActivity(32005): Connected to WIFI

D/MainActivity(32005): CHANGE HAPPENED

D/MainActivity(32005): Connected to WIFI

I am not able to understand why the Logcat reported this message three times. Can anyone please help me understand this behavior.

This is my manisfest file.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.wififourghandoff"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET"/>
     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

THIS IS MY OBSERVATION.

Is the Sequence like the Following :

Wifi to Mobile :
1. Network Info is NULL
2. Netowrk Info object Exists and the “reason(networkInfo.getReason()” is dataEnabled.

From Mobile to Wifi :
1. Broadcast Message Received.
2. Netowrk Info object Exists and the “reason(networkInfo.getReason()” is dataDisabled.
3. NetworkInfo with Exists withe “reason(networkInfo.getReason()” as null

MY Device is Camped on to WIFI Initially
My Logcat

D/MainActivity( 880): CHANGE HAPPENED

D/MainActivity( 880): Connected To: WIFI

D/MainActivity( 880): NUMBER: 1

D/MainActivity( 880): isConnectedOrConnecting: true

D/MainActivity( 880): isConnected: true

D/MainActivity( 880): isFailover: false

D/MainActivity( 880): Reason :null

D/MainActivity( 880): Details CONNECTED

D/MainActivity( 880): noConnectivity: false

D/MainActivity( 880): reason: null

D/MainActivity( 880): DONE

NOW WIFI is Turned OFF. So Now My device moves into MOBILE. Following is the Logcat.

D/MainActivity( 880): CHANGE HAPPENED

D/MainActivity( 880): CHANGE HAPPENED

D/MainActivity( 880): Connected To: mobile

D/MainActivity( 880): NUMBER: 0

D/MainActivity( 880): isConnectedOrConnecting: true

D/MainActivity( 880): isConnected: true

D/MainActivity( 880): isFailover: true

D/MainActivity( 880): Reason :dataEnabled

D/MainActivity( 880): Details CONNECTED

D/MainActivity( 880): noConnectivity: false

D/MainActivity( 880): reason: dataEnabled

D/MainActivity( 880): DONE

NOW my WIFI is turned on. And my device camps back to Wifi.

D/MainActivity( 880): CHANGE HAPPENED

D/MainActivity( 880): Connected To: WIFI

D/MainActivity( 880): NUMBER: 1

D/MainActivity( 880): isConnectedOrConnecting: true

D/MainActivity( 880): isConnected: true

D/MainActivity( 880): isFailover: false

D/MainActivity( 880): Reason :null

D/MainActivity( 880): Details CONNECTED

D/MainActivity( 880): noConnectivity: false

D/MainActivity( 880): reason: null

D/MainActivity( 880): DONE

D/MainActivity( 880): CHANGE HAPPENED

D/MainActivity( 880): Connected To: WIFI

D/MainActivity( 880): NUMBER: 1

D/MainActivity( 880): isConnectedOrConnecting: true

D/MainActivity( 880): isConnected: true

D/MainActivity( 880): isFailover: false

D/MainActivity( 880): Reason :null

D/MainActivity( 880): Details CONNECTED

D/MainActivity( 880): noConnectivity: false

D/MainActivity( 880): reason: dataDisabled

D/MainActivity( 880): DONE

D/MainActivity( 880): CHANGE HAPPENED

D/MainActivity( 880): Connected To: WIFI

D/MainActivity( 880): NUMBER: 1

D/MainActivity( 880): isConnectedOrConnecting: true

D/MainActivity( 880): isConnected: true

D/MainActivity( 880): isFailover: false

D/MainActivity( 880): Reason :null

D/MainActivity( 880): Details CONNECTED

D/MainActivity( 880): noConnectivity: false

D/MainActivity( 880): reason: null

D/MainActivity( 880): DONE

Thanks & Regards,
Yuvi

  • 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-09T15:06:40+00:00Added an answer on June 9, 2026 at 3:06 pm

    I think if you log the Extra content the behavior might make more sense:

    http://developer.android.com/reference/android/net/ConnectivityManager.html#CONNECTIVITY_ACTION

    A change in network connectivity has occurred. A connection has either been established or lost. The NetworkInfo for the affected network is sent as an extra; it should be consulted to see what kind of connectivity event occurred.

    If this is a connection that was the result of failing over from a disconnected network, then the FAILOVER_CONNECTION boolean extra is set to true.

    For a loss of connectivity, if the connectivity manager is attempting to connect (or has already connected) to another network, the NetworkInfo for the new network is also passed as an extra. This lets any receivers of the broadcast know that they should not necessarily tell the user that no data traffic will be possible. Instead, the reciever should expect another broadcast soon, indicating either that the failover attempt succeeded (and so there is still overall data connectivity), or that the failover attempt failed, meaning that all connectivity has been lost.

    For a disconnect event, the boolean extra EXTRA_NO_CONNECTIVITY is set to true if there are no connected networks at all.

    My Interpretation of what is going on with the three events when WiFi is enabled:

    1. First event is simply informing you that WiFi is enabled.
    2. Second event is informing you that the cellular network connection is
      disabled and that there is another available network (WiFi). This
      is the event that has the NetworkInfo.
    3. This is essentially a duplicate of event 1. Whenever a disconnected event happens with a NetworkInfo, Android promises that it will follow up with a connection success/failure event for the network in the NetworkInfo

    So, it’s a little redundant for you, but this is normal behavior for the Android. Here are some logs from my experiment:

        08-14 10:58:04.498: DEBUG/WiFiBroadcastReceiver(9161): Bundle[{networkInfo=NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), roaming: false, failover: false, isAvailable: true, inetCondition=0}]
        08-14 10:58:04.779: DEBUG/WiFiBroadcastReceiver(9161): Bundle[{extraInfo=VZWINTERNET, otherNetwork=NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), roaming: false, failover: false, isAvailable: true, reason=dataDisabled, networkInfo=NetworkInfo: type: mobile[LTE], state: DISCONNECTED/DISCONNECTED, reason: dataDisabled, extra: VZWINTERNET, roaming: false, failover: false, isAvailable: true, inetCondition=0}]
        08-14 10:58:04.779: DEBUG/WiFiBroadcastReceiver(9161): ***********Network Info ******
        08-14 10:58:04.779: DEBUG/WiFiBroadcastReceiver(9161): Connected To: WIFI
        08-14 10:58:04.779: DEBUG/WiFiBroadcastReceiver(9161): Network Type: 1
        08-14 10:58:04.779: DEBUG/WiFiBroadcastReceiver(9161): isConnectedOrConnecting: true
        08-14 10:58:04.779: DEBUG/WiFiBroadcastReceiver(9161): isConnected: true
        08-14 10:58:04.779: DEBUG/WiFiBroadcastReceiver(9161): isFailover: false
        08-14 10:58:04.779: DEBUG/WiFiBroadcastReceiver(9161): Reason :null
        08-14 10:58:04.779: DEBUG/WiFiBroadcastReceiver(9161): Details: CONNECTED
        08-14 10:58:04.779: DEBUG/WiFiBroadcastReceiver(9161): noConnectivity: false
        08-14 10:58:04.779: DEBUG/WiFiBroadcastReceiver(9161): reason: dataDisabled
        08-14 10:58:04.779: DEBUG/WiFiBroadcastReceiver(9161): ******************************
        08-14 10:58:04.779: DEBUG/WiFiBroadcastReceiver(9161): Bundle[{networkInfo=NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), roaming: false, failover: false, isAvailable: true, inetCondition=0}]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This post may seem overly long for just the short question at the end
This may be a pathetically simple problem, but I cannot seem to format the
this may sound pretty straight forward, but still I want to post this question
this may seem like a stupid question, but it is stumping me nontheless. I'm
It may seem to be very easy for you guys but I'm kinda new
Ok this may seem like a bit of a noob question but one many
this may seem trivial but I'm setting up, on a profile form page I'm
I'm pretty new to MVC so this may seem like an obvious question, but
I've asked this question before and so the other post may be closed. But,
I seem to be having a very simple problem but I can't wrap my

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.