Hi all,
I have searched the forum and there are several threads on how to get the SSID of the connected Wifi, however, I could not find one that works on Android 10.
Currently, I'm using the following code, which works for Android 8.1 and 9:
I have added to the manifest: AddPermission (android.permission.ACCESS_NETWORK_STATE) and request runtime permission ACCESS_COARSE_LOCATION.
The code works for most devices with Android 8 and 9, only few devices with Android 5, 7, 8.1, 9 give an error in line 8 (R.RunMethod("getExtraInfo")):
Non-fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
However, this code does not work on Android 10 (testing on an Huawei P30).
Does anyone have a reliable way of getting the SSID in Android 10?
Thanks a lot,
Johannes
I have searched the forum and there are several threads on how to get the SSID of the connected Wifi, however, I could not find one that works on Android 10.
Currently, I'm using the following code, which works for Android 8.1 and 9:
B4X:
Dim R As Reflector
Dim SSID As String
R.Target = R.GetContext
Try
R.Target = R.RunMethod2("getSystemService", "connectivity", "java.lang.String")
R.Target = R.RunMethod("getActiveNetworkInfo")
R.Target = R.RunMethod("getExtraInfo")
End Try
I have added to the manifest: AddPermission (android.permission.ACCESS_NETWORK_STATE) and request runtime permission ACCESS_COARSE_LOCATION.
The code works for most devices with Android 8 and 9, only few devices with Android 5, 7, 8.1, 9 give an error in line 8 (R.RunMethod("getExtraInfo")):
Non-fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
However, this code does not work on Android 10 (testing on an Huawei P30).
Does anyone have a reliable way of getting the SSID in Android 10?
Thanks a lot,
Johannes
Last edited: