Hi
I have my Main Activity calling a sub called using
Then when I run it the App crashes with the following errors
Here is the Activity which is part of an app of multiple activities, If I make an app just with this activity then there is no problem and works ok. If I comment out the 2 places where it writes to the screen then everything works , but I want to display this info.
If youone can point me in the right direction, it would help alot .
Thank you.....
I have my Main Activity calling a sub called using
B4X:
CallSubDelayed(readbarc, "Read_Barcode_update")
Then when I run it the App crashes with the following errors
B4X:
** Activity (main) Pause, UserClosed = false **
** Activity (readbarc) Create, isFirst = false **
** Activity (readbarc) Resume **
** Activity (readbarc) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
** Activity (readbarc) Create, isFirst = false **
running waiting messages (1)
Error occurred on line: 46 (readbarc)
java.lang.RuntimeException: Object should first be initialized (Label).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at anywheresoftware.b4a.objects.TextViewWrapper.setText(TextViewWrapper.java:38)
at java.lang.reflect.Method.invoke(Native Method)
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 anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:163)
at com.AB.ABZxing.ABZxing$1.ResultArrived(ABZxing.java:96)
at anywheresoftware.b4a.BA$4.run(BA.java:523)
at anywheresoftware.b4a.BA.setActivityPaused(BA.java:408)
at dia.stock.readbarc.afterFirstLayout(readbarc.java:106)
at dia.stock.readbarc.access$000(readbarc.java:17)
at dia.stock.readbarc$WaitForLayout.run(readbarc.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:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
** Activity (readbarc) Resume **
Here is the Activity which is part of an app of multiple activities, If I make an app just with this activity then there is no problem and works ok. If I comment out the 2 places where it writes to the screen then everything works , but I want to display this info.
If youone can point me in the right direction, it would help alot .
Thank you.....
B4X:
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim mResult As String
Dim job2 As HttpJob
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim Button1 As Button
Dim myABBarcode As ABZxing
Dim Label1 As Label
Dim MyPhone As PhoneId
Dim lbl As Label
End Sub
Sub Read_Barcode_update
lbl.Initialize("Label1")
Activity.LoadLayout("peterbarcodetest")
Label1.Text = mResult
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
myABBarcode.ABGetBarcode("myabbarcode", "")
End Sub
Sub myABBarcode_BarcodeFound (barCode As String, formatName As String)
Label1.Text = barCode
mResult = barCode
job2.Initialize("Job2", Me)
job2.PostString("http://www.******.co.za/sen_post.php","Barc="&mResult&"&Location=DBN&User="&MyPhone.GetSimSerialNumber&"")
End Sub
Sub myABBarcode_Canceled()
Label1.Text = "Canceled"
mResult = "Canceled"
End Sub
Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Label1.Text = "updated"
Else
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub