Skip to content Skip to sidebar Skip to footer

Clear Another App's Notification Via The Accessibility Api

My app is using the Accessibility API to catch notifications generated by other apps and act on them. I'd like to add a feature where the original notification (generated by some

Solution 1:

No, you cannot clear other app's notifications (thankfully).

Solution 2:

publicvoidonAccessibilityEvent(AccessibilityEvent event) {
        // TODO Auto-generated method stubif (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) {
            //Do something, eg getting packagename
            final String packagename = String.valueOf(event.getPackageName());
            final String text = String.valueOf(event.getText());

            if(TARGET_PACKAGE.equals(packagename)){
                Notification n = (Notification) event.getParcelableData();

                try{
                        n.deleteIntent.send(this,0,new Intent());
                }catch(Exception e){e.printStackTrace();}
        }
} 

If deleteIntent of the notification was defined already, can cancel it.

Post a Comment for "Clear Another App's Notification Via The Accessibility Api"