Android Question Notification click do event-NB6 Notification

takhs123

Member
I try to make a notification which, when user press it, it will open my app and navigate the webview to specific link.
If I put "Main" as fourth element of notification Build it will open my app only,as it should do.
I tried to relpace Main with a function but logger show me problem and it opens me the NB6 library.
How could be done?

Notification Function
B4X:
Sub Process_Globals
    Dim nf As NB6
End Sub
Sub new_Anouncment_notification(text As String)
    Private smiley As Bitmap
    smiley = LoadBitmapResize(File.DirAssets, "iconb.png", 24dip, 24dip, False)
    nf.Initialize("default", Application.LabelName, "HIGH").AutoCancel(True).SmallIcon(smiley)
    nf.Build("Notification", text, "tag", Navigate_function).Notify(1)
End Sub

Error Message
Error:
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:90)
    at b4a.example.nb6._createintent(nb6.java:493)
    at b4a.example.nb6._build(nb6.java:234)
    at b4a.example.eclass_background_work._new_anouncment_notification(eclass_background_work.java:245)
    at b4a.example.eclass_background_work._check_for_new_anouncment(eclass_background_work.java:178)
    at b4a.example.eclass_background_work._processhtml(eclass_background_work.java:595)
    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$2.run(BA.java:370)
    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:6694)
    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:6094)
    ... 22 more
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
I tried to relpace Main with a function but logger show me problem and it opens me the NB6 library.
You MUST define a ACTIVITY or a Service here. You can NOT define a function here.

Set your activity and call the function in the activity by yourself.
 
Upvote 0
Top