Android Question expected receiver of type anywheresoftware.b4a.AbsObjectWrapper

Frank Cazabon

Member
Licensed User
Longtime User
My code is crashing on the second line below whenever a bluetooth scanner is connected to my tablet.

B4X:
Public Sub AddItemsToList(li As List, full As String)
    If li.IsInitialized = False Then Return

The error is:

java.lang.NullPointerException: expected receiver of type anywheresoftware.b4a.AbsObjectWrapper, but got null

What am I doing wrong?
 

Frank Cazabon

Member
Licensed User
Longtime User
Here's the short version of how it is getting called at this time:

B4X:
Sub Activity_Create(FirstTime As Boolean)
   
    svwAWB.Initialize(Me, "svwAWB")
    svwDelivery.Initialize(Me, "svwDelivery")

    Activity.LoadLayout("MainMenu")

    tbhMain.AddTab("Select Route","SelectRoute")
    tbhMain.AddTab("Load","Load")
    tbhMain.AddTab("Approve","Approve")
    tbhMain.AddTab("Deliver","Deliver")
    tbhMain.AddTab("Upload","Upload")

    If FirstTime Then
   
        Dim DeliveryAWBs As List
        DeliveryAWBs = BuildDeliveryList
        DeliveryIndex = svwDelivery.SetItems(DeliveryAWBs)

        Dim AWBs As List
        AWBs = BuildLoadList
        AWBIndex = svwAWB.SetItems(AWBs)
    Else
        svwAWB.SetIndex(AWBIndex)
        svwAWB.AddItemsToList(AWBs, "") ' this seems to be where it is being called.
        svwDelivery.SetIndex(DeliveryIndex)
        svwDelivery.AddItemsToList(DeliveryAWBs, "")
       
    End If
 
Upvote 0

Frank Cazabon

Member
Licensed User
Longtime User
OK, that question got me thinking and apparently AWBs at that point in time shows up as "Error evaluating expression" in the Watch window. SO I guess I need to check if AWBs exists at that point in time. How would I do that?
 
Upvote 0

Frank Cazabon

Member
Licensed User
Longtime User
Tried that but get this error now:

java.lang.RuntimeException: Unexpected command: 0

The activity create seems to get called when the bluetooth device is connected.
 
Upvote 0
Top