问题
I've looked through countless threads regarding the same topic, but have not found any working answers. My app has min API level 21, target API level 29, and I'm testing on a Samsung S9 with Android Oreo (8.1, API 27). None of the methods for pushing notifications (that I've found) seem to be working when the application is swiped away from recents.
In all the methods I tried, all notifications are working when the application is left on.
What I've tried:
- Scheduling notifications with AlarmManager
- Scheduling notifications with broadcast receiver
- Scheduling notifications with WorkManager
- Restarting a service in onTaskRemoved() (with AlarmManager, did not work)
- Calling an activity in onTaskRemoved(), then calling finish() to prevent application from force closing (did not work)
- Clean reinstall of application on my phone, invalidation of caches in Android Studio
*I am not on any of the Chinese ROMS (frequently mentioned problem) *My phone is not entering doze mode, notifications are not received even when the screen is on in another active application activity
In addition, I don't see a point in trying to schedule notifications with JobScheduler, Firebase, or Google Cloud. From what I read, Google's WorkManager uses the appropriate notification scheduling system, so all of those should be covered. Please correct me if I'm wrong.
I would like to ask for a solution that can either:
- Directly allow my application to receive notifications after being swiped from recents
OR
- Allow my application to stay open after being swiped from notifications (In other words, the Android log doesn't disconnect from JVM)
I feel like I'm missing something, because most Android apps are still able to fire notifications when the app is closed (I always swipe apps from recent after using them, and their notifications are working fine).
Any help would be appreciated :)
来源:https://stackoverflow.com/questions/57640839/notifications-not-running-when-is-app-is-swiped-from-recents-samsung-s9-running