Android Question Error on second execution

AndroidMadhu

Active Member
Licensed User
Hello,
I am getting the below error while executing the code on second run.
B4X:
FetchInvoice
actinvoice_jobdone (java line: 176)
java.lang.RuntimeException: Object should first be initialized (Label).
Did you forget to call Activity.LoadLayout?
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
at anywheresoftware.b4a.objects.TextViewWrapper.setText(TextViewWrapper.java:39)
at qcpl.wito.cab.actinvoice._jobdone(actinvoice.java:176)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1178)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6820)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:922)
actinvoice_jobdone (java line: 176)
java.lang.RuntimeException: Object should first be initialized (Label).
Did you forget to call Activity.LoadLayout?
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
at anywheresoftware.b4a.objects.TextViewWrapper.setText(TextViewWrapper.java:39)
at qcpl.wito.cab.actinvoice._jobdone(actinvoice.java:176)
at java.lang.reflect.Method.invoke(Native Method)

But when I am running the code at first time I am not getting any error.
below is my code details :
B4X:
Sub B4XPage_Appear
Dim jobFetchTripDetail As HttpJob
jobFetchTripDetail.Initialize("FetchInvoice",Me)
jobFetchTripDetail.Download("http://<ipAdrress>;& B4XPages.MainPage.srvIP &":xxxx/getCustTripDetail?auth=" & B4XPages.MainPage.SelectedAuthCode)
End Sub
**********************************
Sub JobDone (Job As HttpJob)
Dim Query As String
Dim str As String
Dim totalAmount As String
Dim pay_type As String
Dim taxAmount As String
Dim baseAmount As String
Dim discountAmount As String
Dim cancelAmount As String

If Job.Success = True Then
Select Job.JobName
Case "FetchInvoice"
Log("FetchInvoice")
Dim parser As JSONParser
parser.Initialize(Job.GetString)
Dim r As Map = parser.NextObject
Dim tripCost As List = r.Get("tripCost")
For Each coltripCost As Map In tripCost
totalAmount = coltripCost.Get("totalAmount")
pay_type = coltripCost.Get("pay_type")
taxAmount = coltripCost.Get("taxAmount")
baseAmount = coltripCost.Get("baseAmount")
discountAmount = coltripCost.Get("discountAmount")
cancelAmount = coltripCost.Get("cancelAmount")
Next
lblTotal.Text=totalAmount
lblSubTotal.Text=totalAmount
lblCgst.Text=Round2(taxAmount/2,2)
lblSgst.Text=Round2(taxAmount/2,2)
lblBeforeTax.Text=baseAmount
lblTotal2.Text=totalAmount
lblPayMode.Text=pay_type
lblTripFare.Text=totalAmount
lblDiscount.Text=discountAmount
lblCancellationCharge.Text=cancelAmount
End Select
End If
Job.Release
End Sub

Please advice

Thanks
 

AndroidMadhu

Active Member
Licensed User
@Erel.. I have checked the above document and tried the code including
. But no luck. I am getting error at second time. But first time it is running fine.
The below is my code :
B4X:
Sub B4XPage_Appear
Dim totalAmount As String
Dim pay_type As String
Dim taxAmount As String
Dim baseAmount As String
Dim discountAmount As String
Dim cancelAmount As String

Dim jobFetchTripDetail As HttpJob
jobFetchTripDetail.Initialize("FetchDriver",Me)
jobFetchTripDetail.Download("http://&quot;& B4XPages.MainPage.srvIP &":xxxx/getCustTripDetail?auth=" & B4XPages.MainPage.SelectedAuthCode)
Wait For (jobFetchTripDetail) JobDone(jobFetchTripDetail As HttpJob)
If jobFetchTripDetail.Success Then

Dim parser As JSONParser
parser.Initialize(jobFetchTripDetail.GetString)
Dim r As Map = parser.NextObject
Dim tripCost As List = r.Get("tripCost")
For Each coltripCost As Map In tripCost
totalAmount = coltripCost.Get("totalAmount")
pay_type = coltripCost.Get("pay_type")
taxAmount = coltripCost.Get("taxAmount")
baseAmount = coltripCost.Get("baseAmount")
discountAmount = coltripCost.Get("discountAmount")
cancelAmount = coltripCost.Get("cancelAmount")
Next
lblTotal.Text=totalAmount
lblSubTotal.Text=totalAmount
lblCgst.Text=Round2(taxAmount/2,2)
lblSgst.Text=Round2(taxAmount/2,2)
lblBeforeTax.Text=baseAmount
lblTotal2.Text=totalAmount
lblPayMode.Text=pay_type
lblTripFare.Text=totalAmount
lblDiscount.Text=discountAmount
lblCancellationCharge.Text=cancelAmount
End If
jobFetchTripDetail.Release
End Sub

Thanks
 
Upvote 0
Top