I use NotificationListenerService to catch notifications and elaborate them in my application. App works great and onNotificationPosted is always called, but after a while (Few hours) it stops being called and the app stops working.
It gets back to work only if I reboot my device or if I revoke and grant again notification access to the application.
- App does have notification access enabled.
App does have service on AndroidManifest.
<service android:name=".NotificationService" android:label="@string/app_name" android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"> <intent-filter> <action android:name="android.service.notification.NotificationListenerService"/> </intent-filter> </service>
App is a release version (Same problem on debug version though).
- It has been tested on Android Lollipop, Marshmallow and Nougat, same result.
- It has been tested in different devices running the same Android version.
- App stops working in both background and activity displayed on screen.
- It works again if I reinstall the application, but this is already included in ‘revoke and grant notification access again’ previously mentioned.
- App includes AdMob banner on bottom, is it a possible problem?
I read Android has a cache problem or something like that. Is this the problem? Is there any permanent solution that I couldn’t find anywhere?