B4A Library Wifi Library

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Thanks, for the library!

Please, I need to get the MAC address of my tablet, but if I set this

B4X:
dim edMac as edittext
dim ab as ABWifiInfo

edMac.Text = AB.MacAddress

don't work. Why?
 
Last edited:

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
The logs are empty? If you are using B4A-Bridge with Android 4.1+ devices then the logs will only appear in debug mode.

Hi,
it's empty the Log(AB.MacAddress)
 

jefflynn1974

Member
Licensed User
Longtime User
Hi!

I have a question. I would like to use this libary to get location by wifi wihout using GPS. Is it possible somehow? I would like to avoid turn the GPS on.

Thanks!
 

appie21

Active Member
Licensed User
Longtime User
Hi
I have a question about your tutorial
if I do not run code line 'if I rem this line the program not work why? Msgbox (myWifi.ABGetCurrentWifiInfo().SSID, "")

the button click not work correct

What do I wrong


B4X:
Sub Process_Globals
  Dim myWifi As ABWifi
End Sub

Sub Globals
    Dim Button1 As Button
End Sub

Sub Button1_Click
    Dim r As Boolean
    Dim a As Int
    r = myWifi.ABLoadWifi()
    If r = True Then
      'if I rem this line the program not work why?  Msgbox (myWifi.ABGetCurrentWifiInfo().SSID, "")
      For a = 0 To myWifi.ABNumberOfAvailableWifiNetworks - 1
        Msgbox (myWifi.ABGetWifiNetwork(a).SSID & " " & myWifi.ABGetWifiNetwork(a).Level, "")
      Next
    Else
      Msgbox(myWifi.ABWifiLastError,"")
    End If
End Sub
 

peacemaker

Expert
Licensed User
Longtime User
myWifi.ABGetWifiNetwork(id).MacAddress is always empty string. Under Android 4.2.1 and 4.0.3.
Is it known ?
It's for others WiFi APs around, that are all password protected.

Bug ?
 

Avansys

Member
Licensed User
Longtime User
Can this library return the info of each network saved in the device?
 

peacemaker

Expert
Licensed User
Longtime User
I could collect max these:
B4X:
current_wifi_ap:"Pmaker.biz"
newtwork=GPRS
CID=1636
LAC=6315
network cells (ID,signal_strength): (ArrayList) [1631,13, 2613,9, 2614,8, 1654,6, 1634,6, 2618,5]
APN=Megafon internet, MCC=250, MNC=02
datastate=DISCONNECTED
SIM card line number=
SIM card serial number=897010270107082139ff
IP=192.168.1.33
WiFi IP=192.168.1.33
WiFi networks around:4
WiFi points (ID, signal_strength)Pmaker.biz, -61
MacAddress=
WiFi points (ID, signal_strength)NETGEAR, -62
MacAddress=
WiFi points (ID, signal_strength)admin, -62
MacAddress=
WiFi points (ID, signal_strength)DIR-300NRU, -91
MacAddress=

MACs are anyway empty.
 

Steve Miller

Active Member
Licensed User
Longtime User
The IsConnected connected property doesn't work. I'm connected to my home wifi network (writing this post from my tablet now, so obviously I'm connected to my network, which is connected to the internet), but the wifi library IsConnected property is displaying False.

I've seen others stating the same issue. Is this ever going to be fixed, or do we need to find another method to determine if we are connected to wifi?
I need to be able to determine if I am connected to wifi, what the SSID is of the connection is, and what the strength of the signal is.
 

Peter Simpson

Expert
Licensed User
Longtime User
Hello all,
I had the exact same issue as post #67, I also noticed the same thing. Basically it looks like the For Loop isn't getting enough time to find all the WiFi networks available.

My solution was to add a timer that waited for a couple of seconds before executing the For Loop. My timer solution works perfectly but it's not really and correct solution to the issue mentioned in post #67
 

Dadeda

Member
Licensed User
Longtime User
I'm trying to use this lib to get my location (lat/long) from wifi and not gps but it simply does not work, i always get a null value from ABgetFoundLocation.
I got wifi working for other subs, so i know that it is connected, can anyone help me out? i really need a way to get lat/long coordinates from wifi without using gps.
 

antonomase

Active Member
Licensed User
Longtime User
Like other people, the flag Isconnected does not work.

How can we test if the device is or not connected to a wifi router ?

I try the State value, but it is always COMPLETED event if the wifi is desactivated on the device.

Is it reliable to use LinkSpeed or Frequency to test if the device is or not connected to a router ?

Thanks
 
Last edited:

woniol

Active Member
Licensed User
Longtime User
Hi,
I get this with ABWifi 2.0 example (real device with Android 4.1.2):
B4X:
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:com.ab.abwifidemo
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Get new reading
java.lang.NoSuchFieldError: android.net.wifi.ScanResult.timestamp
    at com.AB.ABWifi.ABWifi$2.onReceive(ABWifi.java:171)
    at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:755)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4867)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
    at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Resume **
 

woniol

Active Member
Licensed User
Longtime User
I use API 21:
C:\Program Files (x86)\Android\android-sdk\platforms\android-21\android.jar
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…