Reputation: 2059
I have a service, which monitors a server for changes.
When I open the app and just press my home button to leave it, all works fine.
But when I kill the app from the "recent apps" view, I don't get any notifications anymore.
I know that there is way, to use startForeground. But then I have to display a notification.
But how does the stackoverflow app work? There is no notification, no entry in the android account manager or anywhere else. But without starting it and without keeping it in the recent view, I get notifications for new answers.
How does it work?
Upvotes: 3
Views: 627
Reputation: 541
Try to start service in another process. This way even if you kill your app through "recent apps", the other process (in which the service runs) will continue running. Also, on the onStartCommand of service, return START_STICKY. This will tell the OS, if for any reason you need to close the service run it again when you have enough resources.
Sorry I do not have enough reputation to put it as comment.
Upvotes: 2