Hey everyone, This question may sounds odd but I am stuck with it .
I have created a standard class and declare a panel into it and loading a layout into the panel that I declared after initializing it.
when I create the class from Activity everything is working fine .
but if I create the class from a service I get NullPointerException.
does that means that I cannot load layout to a panel in standard class if my code is running in a service ?
the creation of panel code looks like following
I have created a standard class and declare a panel into it and loading a layout into the panel that I declared after initializing it.
when I create the class from Activity everything is working fine .
but if I create the class from a service I get NullPointerException.
usercls_vv7 (java line: 77)
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'int anywheresoftware.b4a.BALayout.getWidth()' on a null object reference
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:155)
at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
at b4a.example.testapp.usercls._vv7(usercls.java:77)
at b4a.example.testapp.myservice._vvvv2(myservice.java:272)
at b4a.example.testapp.myservice._audioclient_onparticipants(myservice.java:238)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.BA$2.run(BA.java:387)
at android.os.Handler.handleCallback(Handler.java:900)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8387)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'int anywheresoftware.b4a.BALayout.getWidth()' on a null object reference
at anywheresoftware.b4a.keywords.LayoutBuilder.runScripts(LayoutBuilder.java:205)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:143)
... 14 more
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int anywheresoftware.b4a.BALayout.getWidth()' on a null object reference
at anywheresoftware.b4a.keywords.LayoutBuilder.setScaleRate(LayoutBuilder.java:220)
at b4a.example.testapp.designerscripts.LS_userpanelitem.LS_general(LS_userpanelitem.java:11)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.keywords.LayoutBuilder.runScriptMethod(LayoutBuilder.java:215)
at anywheresoftware.b4a.keywords.LayoutBuilder.runScripts(LayoutBuilder.java:195)
... 15 more
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'int anywheresoftware.b4a.BALayout.getWidth()' on a null object reference
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:250)
at anywheresoftware.b4a.BA$2.run(BA.java:387)
at android.os.Handler.handleCallback(Handler.java:900)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8387)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'int anywheresoftware.b4a.BALayout.getWidth()' on a null object reference
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:155)
at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
at b4a.example.testapp.usercls._vv7(usercls.java:77)
at b4a.example.testapp.myservice._vvvv2(myservice.java:272)
at b4a.example.testapp.myservice._audioclient_onparticipants(myservice.java:238)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
... 8 more
Caused by: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'int anywheresoftware.b4a.BALayout.getWidth()' on a null object reference
at anywheresoftware.b4a.keywords.LayoutBuilder.runScripts(LayoutBuilder.java:205)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:143)
... 14 more
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int anywheresoftware.b4a.BALayout.getWidth()' on a null object reference
at anywheresoftware.b4a.keywords.LayoutBuilder.setScaleRate(LayoutBuilder.java:220)
at b4a.example.testapp.designerscripts.LS_userpanelitem.LS_general(LS_userpanelitem.java:11)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.keywords.LayoutBuilder.runScriptMethod(LayoutBuilder.java:215)
at anywheresoftware.b4a.keywords.LayoutBuilder.runScripts(LayoutBuilder.java:195)
... 15 more
does that means that I cannot load layout to a panel in standard class if my code is running in a service ?
the creation of panel code looks like following
B4X:
Public Sub loadPanellayout(awidth As Int, aheight As Int)
usrpnl.Initialize("usrpnl")
usrpnl.SetLayout(0, 0, awidth, aheight)
usrpnl.LoadLayout("userpanelitem")
Log(udisplay)
End Sub