I want to provide the user with toast notifications every 'x' minutes, I tried to do this with the help of service, but when the application was killed, the service stops. The same issue occurs with intent Service as well, what should I be doing in order for me to keep a thread/service in memory even after the application is killed?
The terms of your question are a bit confusing :
But what you want to do is maybe simpler : set a repeating task. For this, you could use the alarm manager.
You can, for instance :
If you combine this approach with the first part of that answer, running your service in a different process, then you can achieve something that's really light weight for the Android device : only your service (in its own process) will wake up at given interval, and the application's process will not be launched by this alarm, but only the service's process.
And about toast notifications, yes, a service is a good place to do it, but the notification bar may be more appropriate to display notifications and notify the user that some event took place inside a background service.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With