Android Question MLScan listSavedNetworks problem <SOLVED>

SimonInCanada

Member
Licensed User
Hi

I am trying to run this code snippet to get a list of saved wifis:

Sub Activity_Resume
Log("Activity_Resume called")
Dim myAPlist As List
myAPlist.Initialize
myAPlist = myScan.listSavedNetworks
Log(myAPlist)
End Sub

but I am getting the error

Process_Globals called
*** Service (starter) Create ***
** Service (starter) Start **
Globals called
** Activity (main) Create, isFirst = true **
Activity_Create completed
** Activity (main) Resume **
Activity_Resume called
Error occurred on line: 198 (Main)
java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference
at wifi.MLwifi$MLWifiScanner.listSavedNetworks(MLwifi.java:997)
at com.msluk.net.siot_approach_data.main._activity_resume(main.java:542)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at com.msluk.net.siot_approach_data.main.afterFirstLayout(main.java:108)
at com.msluk.net.siot_approach_data.main.access$000(main.java:17)
at com.msluk.net.siot_approach_data.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6934)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy **
SENTINEL_MSG_LIBCUTILS
SENTINEL_MSG_LIBLOG

I ran a very similar code snippet yesterday and it worked, but I modified it and started getting this error so I extracted these lines to make things simpler.

Thanks

Simon M
 

Emme Developer

Well-Known Member
Licensed User
Longtime User
Please, use CODE tag when you post a code.
Have you Wifi enabled? You're getting a null object from this line
B4X:
myAPlist = myScan.listSavedNetworks

As i remember this happens when you have not wifi enabled
 
Upvote 0

Ricky D

Well-Known Member
Licensed User
Longtime User
Please, use CODE tag when you post a code.
Have you Wifi enabled? You're getting a null object from this line
B4X:
myAPlist = myScan.listSavedNetworks

As i remember this happens when you have not wifi enabled
So add a try catch and toastmessage the user they need to turn on wifi in the catch
 
Upvote 0

SimonInCanada

Member
Licensed User
Thanks.

It does seem a little odd to have to have to have the actual Wifi radio enabled to manage a memory resource. I want to give my users tha ability to see and eliminate entries which the phone might otherwise log on to (i.e. the phone is used on ships which often have open wifis and I want the users to be able to see and cleanse any instances where the user has logged in to these as apposed to our wifis located at the berths).
 
Upvote 0
Top