Reputation: 5575
Is it possible to invoke an ACTION programatically on a Notification from a NotificationListenerService? I have written a Notification Listener service that reads out all the incoming notifications and dismisses when done. But I'm not sure if we can perform any ACTIONs on the incoming notifications.
For eg: On a WhatsApp message notification I can read the package name, sender and message details but is there a way to send a reply back to the sender? Currently Android Wear is doing this so I'm wondering if it is following a generic approach of acting upon a Notification or it has a specific API to WhatsApp service.
Upvotes: 5
Views: 1552
Reputation: 22168
Yes, you can do it by this function:
sbn.notification.actions[0].actionIntent.send()
Upvotes: 1
Reputation: 21
When ever a whatsapp notification is received via notification listerner service there is one another notification thats received (hidden) which has a tag value something like this [email protected] (xxxxxxx being the phonenumber), I think this somehow holds the key to sending a reply to this user.
I am working on other app logic, which does not require you to send back replies but I found this interesting but could not get enough time to check it myself.
Upvotes: 2
Reputation: 1584
Yes, we can perform actions on notifications. Pushbullet app on Android has an ability to reply to WhatsApp, Hangouts, Facebook messenger etc when user enters the message form desktop which means that there is a way. I am still trying to figure out how to do it.
Upvotes: 0