Hi,
Can someone tell me why I got "java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.ref.Reference.get()' on a null object reference"?
It seems to happen on "p = xui.CreatePanel("").
The complete message is:
Thanks.
Best regards,
André
Can someone tell me why I got "java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.ref.Reference.get()' on a null object reference"?
B4X:
#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim Interval As Int: Interval=1 'om de 5 minuten
Private xui As XUI
Dim Teller
End Sub
Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
End Sub
Sub Service_Start (StartingIntent As Intent)
Log("Gedaan")
StartServiceAtExact(Me, DateTime.Now + Interval * DateTime.TicksPerMinute, True)
TellerNotification
Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
End Sub
Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Service_Destroy
End Sub
Sub TellerNotification
Log("1")
Dim p As Panel
Log("1a")
p = xui.CreatePanel("")
Log("1b")
p.SetLayoutAnimated(0, 0, 0, 24dip, 24dip)
Log("2")
Dim cvs As B4XCanvas
cvs.Initialize(p)
Log("3")
Dim n As NB6
Teller=Teller+1
n.Initialize("default", Application.LabelName, "DEFAULT")
Log("4")
n.OnlyAlertOnce(True)
Log("5")
cvs.ClearRect(cvs.TargetRect)
Log("6")
cvs.DrawText(Teller, cvs.TargetRect.Width / 2, cvs.TargetRect.Height - 5dip, xui.CreateDefaultBoldFont(20), xui.Color_White, _
"CENTER")
Log("7")
cvs.Invalidate
Log("8")
n.SmallIcon(cvs.CreateBitmap)
Log("9")
Dim Notification As Notification = n.Build("CountDownNotification", "...", "", "")
Log("10")
Notification.Notify(1)
Log("11")
cvs.Release
Log("12")
End Sub
It seems to happen on "p = xui.CreatePanel("").
The complete message is:
B4X:
Gedaan
1
1a
trigger_tellernotification (java line: 195)
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.ref.Reference.get()' on a null object reference
at anywheresoftware.b4a.objects.B4XViewWrapper$XUI.CreatePanel(B4XViewWrapper.java:704)
at b4a.example.trigger._tellernotification(trigger.java:195)
at b4a.example.trigger._service_start(trigger.java:171)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at b4a.example.trigger.handleStart(trigger.java:100)
at b4a.example.trigger.access$000(trigger.java:8)
at b4a.example.trigger$2.run(trigger.java:80)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:101)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7425)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Thanks.
Best regards,
André