Android Question Open whatsapp via a notification

cheveguerra

Member
Licensed User
Longtime User
Hi everybody,

I have an app that creates a notification, and in the tag of that notification goes the WA chat to open, so when I click the notification it opens the main activity, the B4XMainPage gets the starting intent from there and then opens whatsapp with an intent:

B4XPage_Appear:
    Dim in As Intent = B4XPages.GetNativeParent(Me).GetStartingIntent
    If in.IsInitialized And in <> OldIntent Then
        OldIntent = in
        If in.HasExtra("Notification_Tag") Then
            Log("Activity started from notification. Tag: " & in.GetExtra("Notification_Tag"))
            Dim i As Intent
            i.Initialize("android.intent.action.SEND", "")
            i.SetType("text/*")
            i.PutExtra("android.intent.extra.TEXT", " ")
            i.PutExtra("jid", in.GetExtra("Notification_Tag"))
            i.SetPackage("com.whatsapp")
            StartActivity(i)
        End If
    End If

So when I click the notification it opens my app, the mainpage appears and then opens whatsapp ... and here goes the question ... is it possible to directly open whatsapp from the notification??

As far as I know, the notification has to call an activity, if I could call a service it would not show my app, and I would like to avoid the opening (or showing) the original app and go directly to WA.

Best regards
 
Top