Это то, что я использовал для отслеживания pu sh уведомления:
public class TrackNotification extends NotificationListenerService {
@Override
public void onNotificationRemoved(StatusBarNotification sbn) {
super.onNotificationRemoved(sbn);
//your code stuff
}
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
super.onNotificationPosted(sbn);
//your code stuff
}
}
В манифесте:
<service android:name=".Test"
android:label="Test"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>