Не знаю при каких условиях, но иногда перестает работать мой сервис по отлову уведомлений.. Вот код:
public class NotificationsService extends NotificationListenerService {
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
Log.d(Constants.LOG_TAG, "onNotificationPosted call");
if (sbn != null) {
final String packageName = sbn.getPackageName();
if (!TextUtils.isEmpty(packageName)) {
if (sbn.getNotification() != null && !TextUtils.isEmpty(sbn.getNotification().tickerText)) {
Intent intent = new Intent();
intent.setAction(Constants.ACTION_NOTIFICATION_MESSAGE);
intent.putExtra("data", sbn);
sendBroadcast(intent);
Log.d(Constants.LOG_TAG, "sendBroadcast: " + Constants.ACTION_NOTIFICATION_MESSAGE);
}
}
Log.d(Constants.LOG_TAG, "onNotificationPosted " + packageName);
}
}
@Override
public void onNotificationRemoved(StatusBarNotification sbn) {
// Nothing to do
}
}
Можете что нибудь подсказать?