Android Question Detect click from notification

Stevenindonesia

Member
Licensed User
How can i detect user launch application by notification?
I am using B4X and i tried below code :

B4X:
Sub Process_Globals
    Private LastIntent As Intent
End Sub

Sub Activity_Resume
    Dim in As Intent = Activity.GetStartingIntent
    If in.IsInitialized And in.HasExtra("Notification_Tag") And in <> LastIntent Then
        LastIntent = in
        Dim tag As String = in.GetExtra("Notification_Tag")
        Msgbox("User clicked notification: " & tag,"Message")
    End If
End Sub

I still couldn't capture the intent and message did not pop up.
 

Stevenindonesia

Member
Licensed User
Erel,

My application are able to get notification. But when i click on the notification... my application will launch. How can i detect that the user launch the application by clicking on notification?
What i wanted to do is - when user launch application by clicking in coming notification, I will show the notification page.


B4X:
Sub Process_Globals
    Private LastIntent As Intent
End Sub

Sub Activity_Resume
    Dim in As Intent = Activity.GetStartingIntent
    If in.IsInitialized And in.HasExtra("Notification_Tag") And in <> LastIntent Then
        LastIntent = in
        Dim tag As String = in.GetExtra("Notification_Tag")
        Log("User clicked notification: " & tag)
    End If
End Sub

The above code doesn't seems to work.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Erel asked you to post the code that generates the notification.

Where is that code?

You just posted the same code as in #1 of this thread.
 
Upvote 0
Top