B4A Library Simple WIFI library Updated V. 3.07 09-05-2018

bgsoft

Well-Known Member
Licensed User
Longtime User
Hi:

I have implemented new methods and events:

Changes v-3.03:
 

bgsoft

Well-Known Member
Licensed User
Longtime User

With the new library 3.03, you can use the NoEventOnSystemScan parameter of the method StartScan.
Or the Stopscan method.

Regards
 

JTmartins

Active Member
Licensed User
Longtime User
Hi, thanks for saying it, I deleted it by mistake .


I've tried it on several devices and it works fine


regards

I have some problems with this...

In one device I always get a false status. Even when connection is achieved.

In other device it reports properly for WPA, but it always reports true for WEP (even trying to connect with wrong password) even when connection is not achieved.
 
Last edited:

hayderOICO

Member
Licensed User
Longtime User
hi

is it possible to add an ap with "advanced settings" ? i.e. static IP configuration?
 

DonManfred

Expert
Licensed User
Longtime User
is it possible to add an ap with "advanced settings" ? i.e. static IP configuration?
Look at the documentation....

addAP (EntryNumber As Int, securityType As String, Password As String) As Boolean
Adds an entry to the wifi manager and connects to it. This method saves the configuration of the new entry onto the device. Use the forgetAP method to delete them. Updated to handle quoted or unquoted SSID strings.
EntryNumber - If you display the string array wifis or the array returned in the getWifiList method UNSORTED, you can pass the Position variable from your ListView_Click event.
Otherwise, you must pass the entry number from the string array since that is what is used as a reference.
securityType - The Access Point security type (returned in the scan result string array)
Password - The password/phrase for the wifi access point. Pass "" for an open network. Handles WEP HEX or text phrases
It is up to you to supply all information. The security type is found in the scan results array.

So i would guess yes.
 

sfgwl

Member
Licensed User
Longtime User
 

bgsoft

Well-Known Member
Licensed User
Longtime User
Hi, I have answered you in the Spanish forum.

Regards
 

mterveen

Member
Licensed User
Longtime User
Potential Bug - If you have a service called "Wifi" in your program it will cause compilation errors with this library.
 

Matt and John

New Member
Licensed User
On some older devices of mine ScanDone returns Results() properly in a service when no activities are showing, but on android 7.0 (or maybe just this device), ScanDone fires, however there are always empty Results() in the service when the activity is paused?

How can I still get Results() in a service when my activity isn't showing? Is it a bug in this library?

*edit - I found it happens only when the home button is pressed, but not when the power button turns off the screen.

Both raise the same activity pause - user closed = false event for activity, im confused
 
Last edited:

FrankBerra

Active Member
Licensed User
Longtime User
Maybe it is something related to this:
Android 6+ requires location for scanning wifi.
Info: https://stackoverflow.com/questions...-m-requires-location-permissions-to-scan-wifi

More detailed infos here:
https://developer.android.com/reference/android/net/wifi/WifiManager.html#getScanResults()
" An app must hold ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission in order to get valid results."

Adding the following lines in your manifest should solve the problem:
AddPermission(android.permission.ACCESS_FINE_LOCATION)
AddPermission(android.permission.ACCESS_COARSE_LOCATION)
 

Michael Wenning

Member
Licensed User
Longtime User
I have tried the scan function on Android 7 Samsung A3.
See attached project file.
I add permissions
AddPermission(android.permission.ACCESS_FINE_LOCATION)
AddPermission(android.permission.ACCESS_COARSE_LOCATION)
in manifest.
I have got always empty results on ScanDone firing.
On some older devices (< Android 6.0) of mine ScanDone returns Results() properly. ( See post #31).
I am thankful for every tip!
 

Attachments

  • MlwifiTest_V5.zip
    441.2 KB · Views: 467

Matt and John

New Member
Licensed User
Still has same issue as in post #31

An example that reproduces the error is attached.

On android 7, when you press 'home', the scan results in log output become 0, however, when you press the power button (to turn screen off), normal scan results are returned.

Both actions trigger the same ** Activity (main) Pause, UserClosed = false ** event

So why does pressing home return 0 wifi results (from a running service)? Is it a library bug? (It works fine on android 6 and below, just not on 7)

*edit - setting target APK to 26 get no scan results at all
 

Attachments

  • demo.zip
    7.5 KB · Views: 326
Last edited:

Michael Wenning

Member
Licensed User
Longtime User
Hello again,
i have updated the Android 7 Samsung A3 mobile phone to Android 8.0
The same code/app as in android 7.0.
No scan results at all. I reinstalled the app and added runtimepermission for the dangerous permissions.
Still no scanresult.
I am happy about any help.
 

Matt and John

New Member
Licensed User
Be sure you have downloaded the SDK you are targeting.

(Click Tools / SDK Manager, search SDK Platform 26 or your manifest's targetSdkVersion="26", select in the list and click Install Selected)
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
An example that reproduces the error is attached
Please create a new thread in the Questions forum for your question.
You are not handling the runtimepermissions correctly.
You are not targeting sdk 26

Running on Samsung Note 8, Android 8, TargetSDK 26

 

Attachments

  • demo_new.zip
    7 KB · Views: 421

Michael Wenning

Member
Licensed User
Longtime User
Thank you Manfred!
I have checked your "Demo new" but no succsess:

** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (activity_permissionresult)
running waiting messages (1)
** Activity (main) Resume **
*** Service (icon) Create ***
** Service (icon) Start **
Wifi scan started!
scan done 0
scan done 0
scan done 0

Verzeichniskonfiguration:

C:\Program Files\Java\jdk-10.0.1\bin\javac.exe

C:\Program Files (x86)\Android\android-sdk\platforms\android-26\android.jar

B4A Vers 8.3

I have tried 3 times with App deinstallation and "Projekt säubern"

I am always asked once for the release and agree.
The runtime permission seem to be okay.
Still no success....

Any idea?

Thanks and regards from Wuppertal
Michael
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…