Reputation: 1
I want to create a alarm function which is running in background even I exit from the application but not based on time. The function which checks for the value from the database, if the condition satisfies the alarm will arise... How to do this?
Upvotes: 0
Views: 216
Reputation: 5651
Start a service which can run indefinitely.
your service would be a content observer or polling the database periodically.
Sqlite Database updates triggers Service to update via Content Observer
Upvotes: 1
Reputation: 13761
Seems that you're looking for a Service
. They have the ability of being run even if your foreground app is not, but the disadvantage that you'll have to be aware it can be killed if the Android OS
needs memory, especially if you're using too much resources.
It's also necessary to handle correctly the events where your Service
may get created/destroyed, so you simply run your Service
where you need and stop it when you no longer need it.
Some useful links:
Upvotes: 1