Howto prevent NotificationListenerService from crashing after clearing app data?

343 Views Asked by At

My question is related to this one. But it's a special case. On Android 7 devices the NotificationListenerService crashes when I clear app data in app settings and restart the app. But the app does not crash at all. Only the service does not work anymore.

Is this maybe related to the permission for "Notification access" not being requested again? If you delete all app data then you must re-grant all permissions again, except from the "Notification access" permission which is still active til you revoke it manually.

Toggling the service and calling requestRebind() as described here does not rebind the service in that special case (= when clearing the app data).

What can I do? Any small hint will help me alot.

You can find some code here. It is from a sample app I once built because I cannot post our productive code from here.

I used adb logcat *:W and I found this line:

05-14 09:15:16.692 863 1731 W ActivityManager: Scheduling restart of crashed service com.xyz.dapp.debug/com.company.subcompany.apppackage.notification.NotificationListener in 1000ms

0

There are 0 best solutions below