vinothp
vinothp

Reputation: 10059

How to repeat certain operation at specific interval?

In my app i am having the function to repeat certain operations every day, every week etc. with out any user interaction. i.e if the user even not using the app the operation has to take place(Insertion of data into database). Searched a lot but couldn't get any idea about achieving this. I thought about Local Notification, but don't know will this be a good idea or is there any better approach to achieve this.

Any help is much appreciated.

Upvotes: 0

Views: 99

Answers (1)

Jeffrey Blattman
Jeffrey Blattman

Reputation: 22637

you want to look into AlarmManager. think of it like unix cron for your android app. in a nutshell, you schedule an Intent to fire in the future. You then write a BroadcastReceiver to handle the intent, and do whatever you want here.

of course, the devil's in the details. pay close attention to things like offloading any time-consuming work from your broadcast receiver to a service thread, and ensuring that you grab a wake lock before hand. these are advanced topics that can't properly be covered in a SO answer.

Upvotes: 2

Related Questions