Android Question NB6 simple notification crashes


Well-Known Member
Licensed User
I keep pulling my hair out on this one:

1. Create a new B4XPages project in B4A
2. Add the NB6 module that comes with B4A
3. Add smiley.png (or another image) to the project
3. Paste the following code in B4XMainPage:

Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private smiley As Bitmap
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    smiley = LoadBitmapResize(File.DirAssets, "smiley.png", 24dip, 24dip, False)

End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Private Sub Button1_Click
    Dim n As NB6
    n.Initialize("default", Application.LabelName, "DEFAULT").AutoCancel(True).SmallIcon(smiley)
    n.Build("Title", "Content", "tag1", Me).Notify(4)
End Sub

Run the program, click the button. This should show a notification, but I get this error:

Error log:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
Error occurred on line: 302 (NB6)
    at java.lang.reflect.Constructor.newInstance0(Native Method)
    at java.lang.reflect.Constructor.newInstance(
    at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(
    at b4a.example.nb6._createintent(
    at b4a.example.nb6._build(
    at b4a.example.b4xmainpage._button1_click(
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(
    at anywheresoftware.b4a.BA.raiseEvent(
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(
    at android.view.View.performClick(
    at android.view.View.performClickInternal(
    at android.view.View.access$3100(
    at android.view.View$
    at android.os.Handler.handleCallback(
    at android.os.Handler.dispatchMessage(
    at android.os.Looper.loop(
    at java.lang.reflect.Method.invoke(Native Method)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Class.getName()' on a null object reference
    at android.content.ComponentName.<init>(
    at android.content.Intent.<init>(
    ... 25 more
** Activity (main) Pause event (activity is not paused). **
** Service (starter) Destroy (ignored)**

What am I doing wrong here?
Last edited:
SOLVED (happens usually a few seconds after posting something here :))

ME should be replaced with MAIN when you're working with B4XPages.


Well-Known Member
Licensed User
SOLVED (happens usually a few seconds after posting something here :))

ME should be replaced with MAIN when you're working with B4XPages.
Upvote 0

Similar Threads