Android Question MLWiFi400 problem or lack of knowledge

hatzisn

Expert
Licensed User
Longtime User
Hi everyone,

I wanted to check if the phone is connected to WiFi
I downloaded MLWifi400 from the following link:

When I try the following code it does not work.

B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private xui As XUI
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private B4XFloatTextField1 As B4XFloatTextField
    Private Button1 As Button
    Private Button2 As Button
    Dim wifi As MLwifi
    Dim rp As RuntimePermissions
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
 
    rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
    rp.CheckAndRequest(rp.PERMISSION_ACCESS_COARSE_LOCATION)
    wifi.debug = True
End Sub

Sub Activity_Resume

End Sub

Sub Activity_PermissionResult (Permission As String, Result As Boolean)
 
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click
    'NO TOAST IN ANDROID 10
 
    Log(wifi.isWifiConnectedQ)  '<== False
    Log(wifi.isWifiConnected)    '<== False
 
    If wifi.isWifiConnected = True Then
        ToastMessageShow("WiFi Connected: " & wifi.isWifiConnected, True)
    End If
 
End Sub

This is the manifest
Manifest Code:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="29"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.

'MLWiFi
AddPermission(android.permission.ACCESS_FINE_LOCATION)
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.ACCESS_WIFI_STATE)
AddPermission(android.permission.CHANGE_WIFI_STATE)
AddPermission(android.permission.INTERNET)

'I added this also
AddPermission(android.permission.ACCESS_COARSE_LOCATION)

Does it requires any other permissions in order to work?
I have added the ACCESS_NETWORK_STATE in Manifest and have requested the ACCESS_FINE_LOCATION and ACCESS_COURSE_LOCATION runtime permission request. But no luck. Is there anything else? I use Android 10.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Permissions:
  • android.permission.ACCESS_FINE_LOCATION
  • android.permission.ACCESS_NETWORK_STATE
  • android.permission.ACCESS_WIFI_STATE
  • android.permission.CHANGE_WIFI_STATE
  • android.permission.INTERNET

From the Original thread. Guess they still apply
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Thanks DonManfred. I added them all. No luck. See again manifest, new code and results in first post.
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Newsflash, the old MLWiFi v(3.06) that I have works (same manifest - same code). I suppose then that something more is needed in order to make MLWiFi400 work.
 
Last edited:
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
I won't be back home until about mid next week, but will look at it then.

- Colin.
 
Upvote 0

pliroforikos

Active Member
Licensed User
Good morning "φίλε μου"

Here there is a nice java code library that you can use. I've tested and give me information about wifi and network.
I made a jar with it here

You can see manifest in the first link project
 
Upvote 0
Top