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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:38:59+00:00 2026-05-21T15:38:59+00:00

I understand that on a wifi network there are sudden disconnections which prevent me

  • 0

I understand that on a wifi network there are sudden disconnections which prevent me from sending messages to my server.

But sometimes there’s still one last chance before the disconnection, for example if the signal is low or the user is trying to turn off the wifi. On those occasions I would like to send a logout message to my server.

How do I detect disconnections like those?

I tried to retrieve changes of connectivity by registering a broadcast listener:

registerReceiver(this,new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
...
public void onReceive(Context context, Intent intent) {
  NetworkInfo info = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
  if( (info.getState()== State.DISCONNECTING) && (info.getType() == ConnectivityManager.TYPE_WIFI) ) {
    //send logout
  }

But it looks like at that time it’s already too late. My logout message doesn’t go through.

Is there a better way?

[Update 1]
I also tried:

if( (info.getDetailedState()== DetailedState.DISCONNECTING) && connectionTypeOK ) {

[Update 2 – SOLUTION]
The solution is, as stated below, using a combination of receiving the RSSI_CHANGED_ACTION and WIFI_STATE_CHANGED_ACTION broadcasts to monitor the signal strength and the WIFI_STATE_DISABLING events respectively. When this happens, I send my logout request. This works exactly as I needed. Thanks!!

  • 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-21T15:39:00+00:00Added an answer on May 21, 2026 at 3:39 pm

    You could try to implement a variable “heartbeat” function, by using WifiManager to detect changes in signal strength. Here you can find some related code, btw.

    Now, once you receive a RSSI_CHANGED notification, according to the corresponding signal strength, you will update the frequency of your app’s “heartbeats” to the server: if the signal is strong, you will only need to notify the server infrequently that the app is alive. Once the signal becomes week, however, just like adrenaline kicking in for a real live being, so should your app notify the server more frequently. If the signal’s strength recovers, you’ll send a specific message to let the server know everything is all right again; if, however, the server does not receive this message in a certain period of time and the “heartbeat” stops – your app ceases notifications for that amount of time – then the server logs it out until receiving from it again.

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

Sidebar

Related Questions

I understand that there are big differences in data-store, but surely since django is
I understand that meteor CAN be used with PhoneGap, but are there any examples
I understand that we can set the various style attributes from code behind using
from what i read i understand that iPhone can determine your location using Wi-Fi.
I understand that render :action only renders an action's view. But I was wondering..
Understand that the subject should be discussed before. But as I haven't found the
I understand that this question may seem somewhat ungrounded, but if someone knows anything
I understand that bigint is not a function but rather a type constructor. That's
I understand that there is both an ANSI standard and an ISO standard for
Understand that 1x1 widget size should be 72 dip x 72 dip, but this

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.