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.
This is the manifest
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.
I wanted to check if the phone is connected to WiFi
I downloaded MLWifi400 from the following link:
MLwifi Library Updated to v4.00
Attached Java Source Code MLWifi.zip - couldn't attach the entire Android Studio project as even zipped it was too big (900 KB) for the forum limits. If you want the entire project, private message me with your email address & I'll send it to you. Library updated to v4.40 Added @Events so the...
www.b4x.com
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: