B4A Library Wifi connect library (WEP,WPA,Open)


New Member
Licensed User

do not speak English, have little programming experience and ask for help

I'm doing a custom wifi network manager

I took example of how to connect on a wifi network and could

to disconnect I'm having problems

I am using the following example

Dim mywifi As VBConnect

Dim Wifi1 As WiFiConnect

Sub WiFiAdd_Click

Wifi1.connectToSSID(Wifi1.WIFI_WPA, “SSID1”, “123456789”)

End Sub

Sub WiFidisconnect_Click

mywifi.RemoveAllSavedNetworks ‘remove all saved networks End Sub

the doubt is, how to disconnect only one specific network, example: "Wifi1. disconnectToSSID ("SSID1") just unplugging "SSID1" network

clean out a Saved on my list of wi-fi network

Hold and thank you in advance

Eynysman Felix Pacheco

Cabo Frio – Rio de Janeiro - Brasil


Licensed User
I am in the same situation as jnbarban - I have a nice little app that connects to a wifi SSID with WPA. However, that connection does not persist. If I go into Wifi, I can then manually save the connection but I need this to happen automatically. Any suggestions?



Well-Known Member
Licensed User
Thanks for share this! I'm testing it and works fine in a simple way! :)
How to make a disconnect method in order to programmatically disconnect from the current connecion ?
I'm not familiar with developing B4A libraries starting from Java code :( Someone can help?


Well-Known Member
Licensed User
Hi to all,
starting from my need a B4A friend "Meli Massimo" provided a library update (Beta version) to test with the following methods:

- DisconnectFromSSID (networkSSID as string)
- GetConfiguredNetworks
- GetWiFiEnabled
- SetWiFiEnabled (enabled as boolean)
- GetWiFiState

Anyone wish to test and improve this useful WiFi library ?
I'm trying to implement a network switch using this library.

So I wish to programmatically change the WiFi connection from a SSID to another SSID.

Attached you can find also the java version.



Well-Known Member
Licensed User
Here is the Java. If you improve it but don't want to post it yourself as a library then repost the source here and I will do it. I was thinking of extending this library but I don't have time to look at it at the moment.
Hi @agraham
I and italians Facebook guys (B4A Italia - https://www.facebook.com/groups/598542593522315/) worked on the WiFiConnect Java source and we update it to version 1.59 introducing several new methods (actually the count is about 50 methods) and fixed bugs within existing ConnectToSSID method (see the java source attached).

At the moment I'm testing 2 new methods : "updateInfo" and "getSSID" but in same cases getSSID return the last connected SSID but my device isn't connected to that SSID.

B4A code that I'm using for the tests (PE1 As PhoneEvents):

Sub PE1_ConnectivityChanged (NetworkType As String, State As String, Intent As Intent)
    Log("ConnectivityChanged: " & NetworkType & ", state = " & State)
    If State="CONNECTED" Then
        If NetworkType = "WIFI" Then
            Private wfm As WiFiConnect
            Private CurrentSSID As String = wfm.getSSID

            ToastMessageShow ("Current SSID = " & CurrentSSID, False)
        End If
    End If
End Sub



Licensed User
what is this error:

main_activity_create (java line: 220)
java.lang.NoClassDefFoundError: anywheresoftware.b4a.jalle007.wificonnect.WiFiConnect
at tt.com.main._activity_create(main.java:220)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at tt.com.main.afterFirstLayout(main.java:84)
at tt.com.main.access$100(main.java:16)
at tt.com.main$WaitForLayout.run(main.java:72)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)

Natal - Brazil

hongbii khaw

Licensed User
Hi all,
First of all, thanks for the library, it's very useful.
I can connect to WPA/WEP without a problem, but it just cannot connect to an OPEN type of network.
Anyone know what's the problem?
Thank you.


Active Member
Licensed User
Hello everyone, this library is a great alternative to MLWIFI / MLSCAN,

I have not previously achieved good results with the MLWIFI / MLSCAN libraries, and recently someone tried to improve MLWIFI for a version 4, but it was unstable in my tests, has moments that work or not, very slow in the search.

So I kept searching until I found this WifiConnect library.

I was very pleased with the response time, it is much faster than the MLSCAN library in network scanning.

I did not find a way to remove the network configuration, someone else said in another post to use a "disableNetwork" function but this does not erase the settings, it just leaves it marked off.

Follows my test app attachment, with it I can add a network similarly to what it was on Android 4.4
(Worked also on Android 7)

Need Dialogs4.01: