Notification Listener Service does not work after app is crashed

后端 未结 3 2049
春和景丽
春和景丽 2020-12-18 08:36

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.

3条回答
  •  悲哀的现实
    2020-12-18 09:03

    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.

提交回复
热议问题