Notification Listener Service does not work after app is crashed

Viewed 5637

I have a problem on my app and I want to report this bug.

I develope the app which can crawls notifications using NotificationListenerService.

It works well.

But NotificationListenerService class has the problem I think.

Because, If the app is crashed, app can't crawl the notification at all, UNTIL the phone reboots.

Is anyone who can solve this problem??

Please help me.

The bug is very clear!! But It is not easy to find the solution ....

3 Answers

I had the same problem. Here are few things that I did and now it works wonderfully for me.

  1. Override onStartCommand, call super and return START_STICKY;
  2. Override onNotificationRemoved, call super and add a toast so that you know in android itself that you service has not died yet whenever you swipe a notification.
  3. Exclude your app from Battery saving list (Settings-> Battery-> Power Saving Exclusion)

Post this the service never dies even after the main app's crash. I dont need to reboot now to restart it.

Related