Cilenco
Cilenco

Reputation: 7117

Get Intent from notification in AccessibilityService

In my app I use an AccessibilityService to get all notifications. That works great but how can I get the intent which is started if the user click on the notification?

Upvotes: 0

Views: 547

Answers (2)

jorge
jorge

Reputation: 36

This raises the intent (Like if the user click the notification)

(This code goes inside the accessibility service)

Notification n = (Notification) event.getParcelableData();

    try {
        n.contentIntent.send();
    } catch (CanceledException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

Upvotes: 2

Emmanuel
Emmanuel

Reputation: 13223

I do not know this for sure but here are my 2-cents. When you create a notification you need to provide a PendingIntent. One of the differences between a PendingIntent and a regular Intent is that the PendingIntent is granted the same permissions the Context it will invoke (i .e. if it starts an Activity it will have the permissions that Activity possesses). If you were able to "intercept" that PendingIntent you would have those permissions. Therefore, I do not think it is possible.

Upvotes: 0

Related Questions