Android Question Error on resumable sub with return value

JDS

Active Member
Licensed User
Longtime User
We've got an resumable sub in the Starter module which sometimes returns an error
using b4a 9.8
I can't get it figured out...

the error is:

starter$ResumableSub_CheckAfterLastZendingresume (B4A line: 3550) Return 1 java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.ref.WeakReference.get()' on a null object reference at anywheresoftware.b4a.keywords.Common.WaitFor(Common.java:1738) at lmmobile.jds.android.starter$ResumableSub_CheckAfterLastZending.resume(starter.java:1491) at lmmobile.jds.android.starter._checkafterlastzending(starter.java:1360) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196) at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1083) at anywheresoftware.b4a.keywords.Common.CallSubNew(Common.java:1030) at lmmobile.jds.android.lm_ophalenversturen$ResumableSub_oGegevensVerzenden_Click.resume(lm_ophalenversturen.java:1946) at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:190) at anywheresoftware.b4a.BA.raiseEvent(BA.java:176) at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1761) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:224) at android.app.ActivityThread.main(ActivityThread.java:7520) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)




Calling code is:
B4X:
Wait For(CallSub(Me,"SendAndWait")) Complete (Result As Int)

Called sub is (also in Starter module)
B4X:
Sub SendAndWait As ResumableSub
    If File.Exists(Globaal.Map_JDS,Globaal.File_Berichten) Then
        PutGelezenBerichten2
    End If
        If Globaal.dolog=1 Then 
            Log("Send and wait")
        End If
    Globaal.CreateDir
    Try
        If File.ListFiles(Globaal.Map_Wachtrij).Size>0 Then
            Wait For(CallSub2(Me,"PutStatus",1)) Complete (Result As Int)
        End If
         
        If File.ListFiles(Globaal.Map_Delete).Size>0 Then
            Wait For(CallSub(Me,"PutZendingDelete")) Complete (Result1 As Int)
        End If
        If File.ListFiles(Globaal.Map_Uren).Size>0 Then
            Wait For(CallSub2(Me,"PutUren",1)) Complete (Result1 As Int)
        End If
        
        If File.ListFiles(Globaal.Map_gps).Size>0 Then
            Wait For(CallSub(Me,"PutGPS")) Complete (Result2 As Int)
        End If
        
        If File.ListFiles(Globaal.Map_Bijrijders).Size>0 Then
            Wait For(CallSub2(Me,"PutBijrijder",1)) Complete (Result3 As Int)
        End If
        
        If File.ListFiles(Globaal.Map_Activiteit).Size>0 Then
            Wait For(CallSub2(Me,"PutActiviteit",1)) Complete (Result4 As Int)
        End If
        
        If File.ListFiles(Globaal.Map_Foto).Size>0 Then
            Wait For(CallSub2(Me,"PutFoto",1)) Complete (Result5 As Int)
        End If
        
        If File.ListFiles(Globaal.Map_ChangeVal).Size>0 Then
            Wait For(CallSub2(Me,"PutChangeChauffeurKenteken",1)) Complete (Result6 As Int)
        End If
        
        If File.ListFiles(Globaal.Map_ProcesCode).Size>0 Then
            Wait For(CallSub2(Me,"PutProcescodes",1)) Complete (Result7 As Int)
        End If
        
        If File.ListFiles(Globaal.Map_VoertuigCtrl).Size>0 Then
            Wait For(CallSub(Me,"PutVoertuigControleWait")) Complete (Result8 As Int)
        End If
        
        If File.ListFiles(Globaal.Map_MainFoto).Size>0 Then
        Wait For(CallSub2(Me,"PutMainFoto",1)) Complete (Result9 As Int)
        End If
    Catch
        Log(LastException)
    End Try
    Return 1 'this triggers the error
End Sub
 

JDS

Active Member
Licensed User
Longtime User
The starter service isn't stopped.
Does it make any difference if i call of directly of with callsub? Buy i will give it a try
 
Upvote 0
Top