B4A Library Wifi Library

Anawratha

Member
Licensed User
Longtime User
Hi, alwaysbusy (...and all others...)!
I tried to implement your lib [1.2] (nice one!!) into my project. Seems to work ok, but:
I can't use your descibed function "ABGetLastKnownLocation" - it's not present. There is only the function "GetLastKnownLocation". If I take this one, I'am just getting a Java-Error: java.lang.NullPointer.Exception.
I'm using B4A 1.5 .
Can anybody help me, please?
:sign0085:
 

droman

Member
Licensed User
Longtime User

I have the same problem :BangHead:
 

bluedude

Well-Known Member
Licensed User
Longtime User
alwaysbusy,

Just a small question. Does the Location stuff use pure CellTower or does it also make a post to a hidden Google Api for looking up the celltower?

Cheers,
 

Inman

Well-Known Member
Licensed User
Longtime User

Just to give a heads up that this logic is not working in Android 4.0 (Ice Cream Sandwich). It always says WiFi state is COMPLETED even when on 3G. The solution using Phone library, mentioned in the thread below, works fine though.

http://www.b4x.com/forum/basic4android-updates-questions/11904-detecting-wifi-connection.html
 

Feri

Member
Licensed User
Longtime User
Null pointer exception

I tried this library with the example, but at
B4X:
Msgbox ("" & ResLocation.Latitude & " - " & ResLocation.Longitude, "")
line I get Java null pointer exception. Another interesting thing that I cannot enable Wifi in emulator, I got "Error" even if I enable data connection with F8. But I should not get null pointer exception even with disabled Wifi, right? (As there is an error handling routine.)
 

Feri

Member
Licensed User
Longtime User

Nobody experienced this problem?
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
How can you detect if wifi is actually on?
I don't want to use the hotspot count = 0 cause that can introduce false negatives.

I dont want to use the wifitoggle lib cause the blackberry playbook doesnt allow it
I dont want to use the phone library cause that adds another permission and people are paranoid about that

B4X:
Sub isWIFI_enabled As Boolean 
   Dim temp As ABWifi 
   Return temp.ABLoadWifi 
End Sub

Wont return false if wifi isnt on

EDIT: Turns out the phone lib doesnt add a permission. It worked fine
 
Last edited:

joolzg

Member
Licensed User
Longtime User
No WIFI but is there a lib that allows access to the WIRED interface that you find on these cheap chinese boxes?

I need to check if WIRED or WIFI is available, and then get the MAC of the one that is connected?

joolz
 
Last edited:

alexposta2

Member
Licensed User
Longtime User
icecream issue

Hi all,
I've a tablet with 4.0.3 android version.
With this os the localization with abwifi don't seem to work

B4X:
Sub myWifi_FoundLocation ()
   Dim ResLocation As ABFoundLocation
   ResLocation = myWifi.ABGetFoundLocation()
   lat = ResLocation.Latitude
   lon = ResLocation.Longitude
   Msgbox ("" & ResLocation.Latitude & " - " & ResLocation.Longitude, "")
End Sub

This sub is not invoked but
B4X:
myWifi.ABLoadWifi()
   reswf = myWifi.ABGetLocation("myWifi")

reswf return true

same code on android 3.2 work fine
any idea?


b4a 1.9

thank you
Alessio
 

CharlesIPTI

Active Member
Licensed User
Longtime User
Fail

Does anyone see a glaring error here?? Because Assuredly ONE of my wifi connections IS connected but the results of this little method all say no connection is actually connected:

Sub WiFiTwo

Dim r As Boolean
Dim a As Int
Dim nFo As ABWifiInfo
r = myWifi.ABLoadWifi()

nFo = myWifi.ABGetCurrentWifiInfo()
Msgbox("Connected 0 :: " & nFo.IsConnected, "")

If r = True Then
Msgbox (myWifi.ABGetCurrentWifiInfo().SSID, "")

For a = 0 To myWifi.ABNumberOfAvailableWifiNetworks - 1

Msgbox(myWifi.ABGetWifiNetwork(a).SSID & " " &
myWifi.ABGetWifiNetwork(a).Level & " " &
myWifi.ABGetWifiNetwork(a).IsConnected, "")

Next
Else
Msgbox(myWifi.ABWifiLastError,"")
End If
End Sub
 

CharlesIPTI

Active Member
Licensed User
Longtime User
Is Connected Broken ??

IS this more appropriate then ??? I had hoped I could check the Is Connected..
PHP:
    Sub WiFiThree 

      Dim r As Boolean
                 Dim a As Int      
      Dim nFo As ABWifiInfo             
      
    r = myWifi.ABLoadWifi()            
      nFo = myWifi.ABGetCurrentWifiInfo()                  
      Msgbox(nFo, "")
      
    If nFo <> Null Then
        Msgbox ("Apparently it is connected", "PLPLP")
        
    Else
       Msgbox ("Apparently NO connection is active ", "PLPLP")
    End If
End Sub
 

flyingbag

Member
Licensed User
Longtime User
Excellent Job AlwaysBusy - great library ! This was exactly what i wanted Thanks so much!
 

CharlesIPTI

Active Member
Licensed User
Longtime User
Three Months ago WiFi Connected

Soooo I guess I should FRESH post the question again Maybe ??

Assuredly ONE of my wifi connections IS connected but the results of this little method all say no connection is actually connected:

B4X:
Sub WiFiTwo

Dim r As Boolean
Dim a As Int
Dim nFo As ABWifiInfo
r = myWifi.ABLoadWifi()

nFo = myWifi.ABGetCurrentWifiInfo()
Msgbox("Connected 0 :: " & nFo.IsConnected, "")

If r = True Then
Msgbox (myWifi.ABGetCurrentWifiInfo().SSID, "")

For a = 0 To myWifi.ABNumberOfAvailableWifiNetworks - 1

Msgbox(myWifi.ABGetWifiNetwork(a).SSID & " " &
myWifi.ABGetWifiNetwork(a).Level & " " &
myWifi.ABGetWifiNetwork(a).IsConnected, "")

Next
Else
Msgbox(myWifi.ABWifiLastError,"")
End If
End Sub
 

petr4ppc

Well-Known Member
Licensed User
Longtime User
b4ppc 1.8 versus basic4ppc 2.50 and abwifi

Dear friends, please very much I need advice.

I had before a few days basic4ppc version 1.8 and I have try this:

Sub Button1_Click
r = myWifi.ABLoadWifi()

If r = True Then
If myWifi.ABGetCurrentWifiInfo().NetworkId >=0 Then
Msgbox (myWifi.ABGetCurrentWifiInfo().NetworkId ,"wifi info")
Else
Msgbox(myWifi.ABGetCurrentWifiInfo().NetworkId ,"wifi info")
End If
Else
Msgbox (myWifi.ABGetCurrentWifiInfo().NetworkId ,"ABLOADWifi errorl")
end If
End Sub

when I have tested it on AVD on PC which was connected via LAN to internet and with basic4ppc 1.8, then I have got results as in real android device, the same results, it does it mean myWifi.ABGetCurrentWifiInfo().NetworkId = 0

now I have version basic4ppc 2.50 I am using the same script and in AVD I become only result myWifi.ABGetCurrentWifiInfo().NetworkId=-1 . But I have PC connected to internet, everything is the same..script, connectiong to internet, only version and computer is new.

The reason is version of BASIC4PPC?

Because when I got myWifi.ABGetCurrentWifiInfo().NetworkId=-1 in AVD and then I install the same program to real device with wifi, then I have right results, it does it mean: myWifi.ABGetCurrentWifiInfo().NetworkId=0 ...

Why with BASIC4PPC v2.50 in AVD I have not right results and only in real device I have good results, please?

Thank you very much, have a good day
p4ppc

My English is not good, I know :sign0013:
 
Last edited:

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
AbWiFi lib

Hi, everybody. I have two doubts, using ABWiFi library. The first is not a doubt, actually, but just experimental evidence. Infact it seems that it is needed a delay of at least two seconds to detect Position. I mean that while ABLoadWifi answers true at lower time rates, the FoundLocation sub is not fired at rates less that two seconds, more or less. (If I am right, of course). The second is a real doubt: I didn't understand whether the library uses the GPS sensor, while connected to WiFi, or not. In my experiments, it seems that coordinates of Gps and WiFi are nearly always the same. Thanks in advance.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…