Detect Wifi dropped or out-of-range

AndyDroid2012

Member
Licensed User
Longtime User
Is it possible to detect that wifi has dropped or is disconnected ?

I used the ABWifi demo and when connected I got

msgbox value = "com.AB.ABWifi.ABWifi$ABWifiinfo@40fe2960"

B4X:
   Dim r As Boolean
   r = myWifi.ABLoadWifi
   Msgbox(myWifi.ABGetCurrentWifiInfo ,"")

Then I turned off wifi in Settings on the tablet and then rebooted the android tablet.

When I run the demo again I get the same value in the msgbox even though the network is off, but Opera browser fails to connect to internet.

What I really want to do is connect to internet website MySQL server and fetch live data,
but if out-of-range fallback to a stored randomaccess table which will be
updated from time to time via wifi when possible.

The user will be informed that the data is not live and will see a datestamp from the last update.

Would it be better to detect a Query failure or timeout and check an error code for "Timeout" than try to detect Wifi failure ?
 

AndyDroid2012

Member
Licensed User
Longtime User
Yes, tested and I think this will do what I want. Once the wifi IP is lost and then re-started (turn off-on wifi in settings)
the program only needs to re-issue ServerSocket1.Listen again before being able to get the IP.

This means the user can wander out of range, get a warning and choose to go back into range and
retry ( issue ServerSocket1.Listen) or if they know the wifi is off or gone then select the randomaccess file.

So this ServerSocket1.Listen code will become part of my general startup procedure.

Thank You
 
Upvote 0
Top