1

I am working on application in which I want to start service at the particular time. I have stored the time in database table. Now, I have the list of the time when service would be started. So, how can I start service at all of these time?

Jaydeepsinh Jadeja
  • 391
  • 2
  • 10
  • 20

2 Answers2

1

You want the Android Alarm Manager:

This class provides access to the system alarm services. These allow you to schedule your application to be run at some point in the future.

Hope this link helps you.

user755278
  • 1,634
  • 3
  • 16
  • 32
  • 1
    You should remember to reset the alarm when phone closes. Here is a stack link for an implementation: http://stackoverflow.com/a/7846622/969325 – Warpzit May 01 '12 at 07:54
  • @Warpzit Why should the OP reset the alarm? And what do you mean with "phone closes"? – THelper May 01 '12 at 08:35
  • 1
    @THelper everytime you shut down phone/the phone crashes/restarts ALL alarms will be lost, you need to set them again. To do this you store the alarms persistent and make a broadcastreceiver on phone startup. – Warpzit May 01 '12 at 08:36
  • @Warpzit In that case you are right.... I got confused by the word "reset". Indeed the OP should write the alarms to file and restore them on startup. – THelper May 01 '12 at 08:42
1

Use android AlarmManager to schedule alarms. you can register multiple alarms for your application.

hope this link helps you

Hassy31
  • 2,793
  • 3
  • 21
  • 37