Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find application which launched a statusBar notification

Was there anyway to find the application which is responsible for statusBar notification?.

One way of finding is selecting the notification Icon. But, if application doesn't add launcher to it, it will be hard to find out. Please let me know if you know any other way to find it. Thanks.

like image 350
Sukumar Avatar asked Dec 05 '25 10:12

Sukumar


1 Answers

I already posted the answer in Detect a new Android notification:

You need to register an AccessibilityService and make sure the user enables the service.

Example for a service:

public class InstantMessenger extends AccessibilityService {

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
    if (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) {
        //Do something, eg getting packagename
        final String packagename = String.valueOf(event.getPackageName());  
}
}

@Override
protected void onServiceConnected() {
    if (isInit) {
        return;
    }
    AccessibilityServiceInfo info = new AccessibilityServiceInfo();
    info.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED;
    info.feedbackType = AccessibilityServiceInfo.FEEDBACK_SPOKEN;
    setServiceInfo(info);
    isInit = true;
}

@Override
public void onInterrupt() {
    isInit = false;
}
}
like image 59
Force Avatar answered Dec 07 '25 23:12

Force



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!