Android Question NB6 simple notification crashes

wimpie3

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:

B4X:
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
    Root.LoadLayout("MainPage")
    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)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.newInstance0(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
    at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(JavaObject.java:91)
    at b4a.example.nb6._createintent(nb6.java:492)
    at b4a.example.nb6._build(nb6.java:233)
    at b4a.example.b4xmainpage._button1_click(b4xmainpage.java:78)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:6597)
    at android.view.View.performClickInternal(View.java:6574)
    at android.view.View.access$3100(View.java:778)
    at android.view.View$PerformClick.run(View.java:25885)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
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>(ComponentName.java:131)
    at android.content.Intent.<init>(Intent.java:6082)
    ... 25 more
** Activity (main) Pause event (activity is not paused). **
** Service (starter) Destroy (ignored)**

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

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

wimpie3

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
Solution

Similar Threads

Top