Android Question How to start another activity when Replacing Notification by NB6

Alain75

Member
I used the simple notification builder and passed an intent in the setinfo2 activity parameter in order to start another application when clicking the notification.

SetInfo2 of Notification:
dim notif as Notification, pm as PackageManager
...
notif.SetInfo2("Title","Text","",pm.GetApplicationIntent(xxx))

I want to switch to NB6 because It would be great to show the icon of the other application with the LargeIcon. I thaught that NB6 will react as Notification when passing the intent in the activity parameter of the build method.

Build of NB6:
dim notif as NB6, pm as PackageManager
...
notif.Build("Title","Text","",pm.GetApplicationIntent(xxx))

Unfortunately, it crashs with error :
B4X:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Class.getName()' on a null object reference

I tried the same approach passing intent in activity parameter of method AddButtonAction2 but with more or less he same problem...

Instead of Me, what should be the activity parameter to launch another application from the notification click ?
Thanks
 

Alain75

Member
Sorry, I forgot to precise that I don't use B4XPage. However, it means that I must start again my application and give in the tag the other application to launch ? It is not really pretty. With the simple notification, the click launchs directly the other application...
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Alain75

Member
Sorry but even if it should work, it doesn't with NB6 object whereas it runs with Notification object. And yet I pass strictly the same object (pm.getApplicationIntent(...))but I get :
B4X:
nb6_createintent (java line: 301)
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:132)
    at android.content.Intent.<init>(Intent.java:7489)
    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.crnotifs.nb6._createintent(nb6.java:301)
    at b4a.crnotifs.nb6._build(nb6.java:189)
    at b4a.crnotifs.tools._notification3(tools.java:1203)
    at b4a.crnotifs.main._notifier(main.java:1197)
    at b4a.crnotifs.main$ResumableSub_NOTIF_Click.resume(main.java:1134)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:275)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:215)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.keywords.Common$15.run(Common.java:1804)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:246)
    at android.app.ActivityThread.main(ActivityThread.java:8653)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
 
Upvote 0
Top