Android Question How to launch a parent app from a notification?

Jerryk

Active Member
Licensed User
Longtime User
I have created a notification with a button. The notification will be triggered based on a schedule when the application is asleep. If I click anywhere and the notification the application will be triggered. That's fine. But how to launch the application when I click the button?

B4X:
    Dim n As NB6
    n.Initialize("default", Application.LabelName, "HIGH").AutoCancel(True).SmallIcon(smiley)
    n.AddButtonAction(smiley, "Open app", MyReceiver, "open")
MyReceiver:
    ....
    If StartingIntent.Action = "open" Then
        ???
        ntf.Cancel(4)
    End If
    ....
 

GMan

Well-Known Member
Licensed User
Longtime User
I use them too and for me the App opens when i click on the Notification...

B4X:
Dim n As NB6
    Dim smiley As Bitmap
    smiley.Initialize(File.DirAssets,"iconauag.jpg")
    n.Initialize("default", Application.LabelName, "DEFAULT").AutoCancel(True).SmallIcon(smiley)
    n.Build("Gestartet","Edelmetallkurse wurden geholt", "tag1", Main).Notify(4) 'It will be Main (or any other activity) instead of Me if called from a service.
 
Last edited:
Upvote 0
Top