Android Question Capturing when WiFi connects/disconnects

Graeme Tacon

Member
Licensed User
Longtime User
Hi,

Is there way to capture when a WiFi connection is made or disconnection happens (similar to capturing droid.bluetooth.device.action.ACL_CONNECTED) for bluetooth.

Thanks
Graeme
 

JTmartins

Active Member
Licensed User
Longtime User
In my case, I took advantage of a timer already present in my app for handling other stuff and inside the timer_tick I've done

B4X:
 Dim server As ServerSocket
 
Try
      server.Initialize(0, "")

    If server.GetMyWifiIP<>"127.0.0.1" Then
        ' WIFI is ON, place here the code you want
    else
        ' WIFI is OFF, place here the code you want
    End If   
Catch

Basicly if server.GetMyWifiIP equals 127.0.0.1 then we are not connected and we are localhost, if it is different then we are connected to a WiFi Network. Please note that we can be connected to a WiFi network but we may not have Internet Access. That situation should be adressed also.
 
Upvote 0
Top