I have one scenario for my application. This is as follow: I want to use countdown timer in background service and it also run in background even if application is removed from stack. Because I want to generate notification for specific time interval even application is not in a stack. Please give me some advice how to manage service after application being destroyed. Thanks in advance.
Check AlarmManager.
Alarms have these characteristics:
- They let you fire Intents at set times and/or intervals
You can use them in conjunction with broadcast receivers to start services and perform other operations.
They operate outside of your application, so you can use them to trigger events or actions even when your app is not running, and even if the device itself is asleep.
- They help you to minimize your app's resource requirements. You can schedule operations without relying on timers or continuously running background services.
A working example can be found here.